Hi,
I am currently working on an app where it can happen that multiple animations of the same object are started simultanously.
to be more specific, the position of the object (an UIView) is changed. while that animation is in progress, a "flip" (setAnimationTransition:forView:cache
animation or other adjustments to the objects position can occur.
After I read through the API reference regarding this I thought those animations should be be queued and fired when the current animation is done. This from commitAnimations:
To simplify things, I wrote a really basic app that only creates a view and executes two move-animations. even this simple app doesn't behave like I want it to: finish one animation, then perform the other. here's the code:
what happens is that the first animation is simply ignored. the view starts at 290,430 and then moves to 0,430.
ideas? did I get something wrong? how do you handle multiple animations properly?
thanks!
PS: setAnimationBeginsFromCurrentState: doesn't work at all for me. I don't want it, but just for testing purposes I tried it but it doesn't change anything.
PPS: funny thing: if I replace the second animation with a flip-animation, the flip-animation is skipped and the first move-animation is executed.
I am currently working on an app where it can happen that multiple animations of the same object are started simultanously.
to be more specific, the position of the object (an UIView) is changed. while that animation is in progress, a "flip" (setAnimationTransition:forView:cache
After I read through the API reference regarding this I thought those animations should be be queued and fired when the current animation is done. This from commitAnimations:
Animations are run in a separate thread so the application is not blocked. In this way, multiple animations can be piled on top of one another.
To simplify things, I wrote a really basic app that only creates a view and executes two move-animations. even this simple app doesn't behave like I want it to: finish one animation, then perform the other. here's the code:
Code:
- (void)viewDidLoad {
UIView *wrapper = [[UIView alloc] initWithFrame:CGRectMake(0,0,30,30)];
wrapper.backgroundColor = [UIColor redColor];
[self.view addSubview:wrapper];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:5];
wrapper.frame = CGRectMake(290,430,30,30);
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationDuration:5];
wrapper.frame = CGRectMake(0,430,30,30);
[UIView commitAnimations];
[super viewDidLoad];
}
ideas? did I get something wrong? how do you handle multiple animations properly?
thanks!
PS: setAnimationBeginsFromCurrentState: doesn't work at all for me. I don't want it, but just for testing purposes I tried it but it doesn't change anything.
PPS: funny thing: if I replace the second animation with a flip-animation, the flip-animation is skipped and the first move-animation is executed.