I have an "AViewController
" is root viewController
and I have an image is playing animation infinite loop.
- (void)rotateImageView
{
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[self.imageViewSpin setTransform:CGAffineTransformRotate(self.imageViewSpin.transform, M_PI_2)];
}completion:^(BOOL finished){
if (finished) {
[self rotateImageView];
}
}];
}
in viewWillAppear
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotateImageView) name:UIApplicationWillEnterForegroundNotification object:nil];
[self rotateImageView];
}
This work great if my application become to active. But when I'm try to presentViewController "CViewController
"
[self.navigationController presentViewController: animated: completion:]
And I have Back button on "CViewController
"
[self dismissViewControllerAnimated:YES completion:^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"checkIsPresent" object:self];
}];
After returning to "AviewController
",animation stops working.
How to solve this issue.
Thank you.
Edit.
Work now I just put [self rotateImage];
in method from postNotification.
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotateImageView) name:UIApplicationWillEnterForegroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkPresentView) name:@"checkIsPresent" object:nil];
[self rotateImageView];
}
-(void)checkPresentView{
//isModalView = false;
[self rotateImageView];
}