我有一个简单的UIImageView (myimageview)加载了一个用于动画的NSArray(animationArray)图像(在my ViewController.m)中)
[self.myimageview setAnimationImages:self.animationArray];
[self.myimageview setAnimationDuration:[self durationTime]];
[self.myimageview setAnimationRepeatCount: 1];
[self.myimageview startAnimating];我知道在哪里使用stopAnimating等等。但是我有个奇怪的问题。当屏幕锁定时,我的动画就不会发生任何变化。任何东西都很有魅力。解锁屏幕后继续。
然而,当我的应用程序进入后台模式,那么整个动画停止(我的动画是2-3分钟,因此它是不可接受的)。我搜索了一下,发现了这个话题:
How to pause a UIImageView animation
上面写着要使用这个代码:
UIView *viewBeingAnimated = //your view that is being animated
viewBeingAnimated.frame = [[viewBeingAnimated.layer presentationLayer] frame];
[viewBeingAnimated.layer removeAllAnimations];
//when user unpauses, create new animation from current position.现在,我试图将其实现到AppDelegate.m中的代码中。
// in -(void)applicationDidEnterBackground:
self.viewController.myimageview.frame = [[self.myimageview.frenchPress.layer presentationLayer] frame];但是,我在 XCode中遇到了这个问题(对于上面的行),我不能继续下去了:
AppDelegate.m:40:47: Receiver type 'CALayer' for instance message is a forward declaration如果我退出到值的后台:self.currentDate (只是为了sidenote,以防我们需要它),我可以节省时间。
如何在没有中断的情况下暂停并播放动画?
发布于 2012-09-05 19:14:35
为了访问CALayer的所有消息和属性,您必须包含其相应的框架头:
#import <QuartzCore/QuartzCore.h>希望这能消除警告。
https://stackoverflow.com/questions/12288221
复制相似问题