2012-09-05 24 views
0

我已经加载了动画的图像的NSArray(animationArray)(一个简单的UIImageView(myimageview)在我ViewController.m)如何在didEnterBackground之后继续使用UIImageView动画?

[self.myimageview setAnimationImages:self.animationArray]; 
[self.myimageview setAnimationDuration:[self durationTime]]; 
[self.myimageview setAnimationRepeatCount: 1]; 
[self.myimageview startAnimating]; 

我知道在哪里使用stopAnimating,等等。不过我有奇怪的问题时。然后当我的应用程序进入背景模式然后整个动画停止(我的动画是二维动画) 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(只是阿里纳斯的情况下,我们需要它)。

如何暂停和播放动画而不中断?

回答

3

为了获得访问的CALayer所有消息和属性,你必须包括其相应的框架标题:

#import <QuartzCore/QuartzCore.h> 

希望这将消除警告。

+0

感谢您解决标题问题的评论,但是我不知道如何从我知道的框架中取消暂停。任何提示,我会帮助吗? –

+0

@FatihArslan尝试'viewBeingAnimated.animationImages = nil;' – 2012-09-05 20:18:53

+0

这将设置我的图像为零。我之前已经有一个数组了。这不会毁了我的照片吗?如果我打电话给我,那么我如何从最新的框架继续。 –

相关问题