解除ViewController iOS后不播放动画
我有一个AViewController是根viewController,我有一个图像是播放动画无限循环解除ViewController iOS后不播放动画,ios,animation,dismiss,Ios,Animation,Dismiss,我有一个AViewController是根viewController,我有一个图像是播放动画无限循环 - (void)rotateImageView { [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ [self.imageViewSpin setTransform:CGAffineTransformRotate(self.imag
- (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];
}
}];
}
在视图中将出现
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotateImageView) name:UIApplicationWillEnterForegroundNotification object:nil];
[self rotateImageView];
}
如果我的应用程序处于活动状态,这将非常有效。但当我尝试演示ViewController CViewController时
[self.navigationController presentViewController:动画:完成:]
我在CViewController上有后退按钮
返回AviewController后,动画停止工作。
如何解决这个问题。
多谢各位
编辑
现在工作我只是把[自转年龄];在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];
}
您不需要添加观察者,也不需要从CViewController发布通知。[self-rotateImageView]方法本身将被调用为AViewController的ViewWillDisplay,并将在解除CViewController时被调用,该post通知我用于另一件事,很抱歉,我将编辑它。因此,从视图将显示它的工作,但我的动画不循环仅运行1/4的圆,动画将停止。您可以尝试调用[view.layer removeAllAnimations];在ViewWillAnk中,我会将其与我的工作代码合并。很好,您已使其工作,将您的编辑作为答案发布
-(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];
}