I'm trying to convert old styled animation to blocks using style. The following code work fine:
[UIView beginAnimations:@"ResizeAndMove" context:nil];
[UIView setAnimationDuration:3];
[UIView setAnimationDelay:0];
[UIView setAnimationBeginsFromCurrentState:YES];
selected_view.frame = targetSlot.frame;
selected_view.center = targetSlot.center;
[UIView commitAnimations];
But this converted wont work:
[UIView animateWithDuration:.3f
animations:^{
selected_view.frame = targetSlot.frame;
selected_view.center = targetSlot.center;
}
];
It says:
2012-10-17 12:32:50.256 myapp[311:207] *** +[UIView
animateWithDuration:animations:]: unrecognized selector sent to class
0x21b989c 2012-10-17 12:32:50.259 myapp[311:207] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason: '***
+[UIView animateWithDuration:animations:]: unrecognized selector sent to class 0x21b989c'
I'm using ios 4.1 with iPad simulator. It compiles ok but always crashes. Can't figure out whats wrong. Even simple example from apple dev:
[UIView animateWithDuration:0.2
animations:^{view.alpha = 0.0;}
completion:^(BOOL finished){ [view removeFromSuperview]; }];
works the same way - it just crashes with the same message (with only "completion:" adding). Whats wrong with argument? Which argument at all? Do I need to import something to add support of blocks? But it compiles fine... I can even see in the UIKit/UIView:
...
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL
...