I recently got a problem with my App.
I usually use
[UIView animateWithDuration:(NSTimeInterval) animations:^{...} completion:^(BOOL finished) {...}];
to make my animations and it worked perfectly until now. Here's my problem's code
UIImageView *someimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someimage"]];
[someimage setFrame:CGRectMake(0, 0, 200, 200)];
[self.view addSubView:someimage];
[UIView animateWithDuration:0.5 animations:^{
[someimage setFrame:CGRectMake(400, 400, 200, 200)];
} completion:^(BOOL finished) {
NSLog(@"Just finish moving some image lets rotate it!");
[UIView animateWithDuration:0.5 animations:^{
someimage.transform = CGAffineTransformMakeRotation(M_PI);
} completion:^(BOOL finished) {
NSLog(@"What just happened?");
}];
}];
I got an image and i moved it from one corner to another position using animations. Then, when the animation finishes I rotate it, but when I make that rotation the UIImageView appear at the corner again.
Can someone explain me why this happen and how to handle it?
Thanks!
The UIView class reference says:
WARNING If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
Changing a view's (or layer's) frame and its transform at the same time does not work as expected. Instead, change the view's center property.