我动画一个UIImageView上下时通过调用其执行以下操作方法animateSettings认为负载:问题恢复UIVIEW动画:ios7?
- (void)animateSettings {
NSLog(@"Animate Settings");
[UIView animateWithDuration:1.0f
delay:0.0f
options:(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewKeyframeAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState)
animations:^{
self.waterImageView.center = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2-75);
}
completion:nil];
}
的问题是,当我退出程序和返回,动画冻结。我明白这是为什么,但我似乎无法弄清楚如何恢复它。
我已经在viewDidLoad方法中设置了NSNotifications
,以便在视图变为活动状态或进入后台时通知我。做以下我称为animateSettings
方法或removeAnimation
方法。
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(animateSettings)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(removeAnimation)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
这里是我的removeAnimation方法
- (void)removeAnimation {
NSLog(@"Remove Animation");
[self.waterImageView.layer removeAllAnimations];
}
问题:即使方法正确调用(NSLogging作品)动画仍然冻结。
当您进入后台时,不需要调用'removeAllAnimations'。它是由系统调用的。 – matt