Reputation: 1019
I have a CABasicAnimation in the viewWillAppear method of "viewA". when I press a button in viewA to go to viewB and then go back to viewA the CABasicAnimation in the viewWillAppear (of viewA) works without problem.
but, when I go from viewA to viewB, and in viewB I resign the application by pressing the home button and return back to the app, the CABasicAnimation in viewWillAppear of viewA doesn't trigger after I've pressed the back button in viewB.
The funny thing is that I also have an animation block in the viewWillAppear and that triggers without any problem in this scenario. so the viewWillAppear method is triggered it's just the CABasicAnimation that doesn't work the first time after resigning and entering the app.
- (void) viewWillAppear:(BOOL)animated {
CAMediaTimingFunction *customTimingFunction;
customTimingFunction=[CAMediaTimingFunction functionWithControlPoints: 0.5f :0.01f :0.1f : 1.f];
CABasicAnimation *buttonAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation"];
buttonAnimation.fromValue=[NSValue valueWithCGPoint:CGPointMake(0,-600)];
buttonAnimation.toValue=[NSValue valueWithCGPoint:CGPointMake(0,0)];
buttonAnimation.duration = 1;
buttonAnimation.removedOnCompletion = NO;
buttonAnimation.fillMode = kCAFillModeForwards;
buttonAnimation.timingFunction = customTimingFunction;
[button.layer addAnimation:buttonAnimation forKey:@"transform.translation"];
}
Upvotes: 0
Views: 1385
Reputation: 151
I`m getting the same case, animation does not start. Using code from here: https://github.com/akaabe/HamburgerButton/blob/master/HamburBtn.m and calling in viewDidAppear toggleAnimation. Only case that is working for me is to use performSelector with delay.
Upvotes: 0
Reputation: 1019
I've found the solution. if I change buttonAnimation.removedOnCompletion = NO;
to change buttonAnimation.removedOnCompletion = YES;
it will trigger every time. even after resign and entering the app.
Upvotes: 3