我是ios developpement的新手。我正在实施Taperecorder项目,其中我有一些CABasicAnimations用于旋转轮子,同时录制音频和播放。一切正常(录制和播放)...但录制时音频,如果我按下主页按钮再次打开应用程序背景录制过程工作细轮动画不旋转..
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat: 2*M_PI];
animation.toValue = [NSNumber numberWithFloat:0.0f];
animation.duration = 4.0f;
animation.repeatCount = INFINITY;
[imageLeft.layer addAnimation:animation forKey:@"SpinAnimation"];
[imageRight.layer addAnimation:animation forKey:@"SpinAnimation"];
答案 0 :(得分:3)
试试这个......
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addAnimation:) name:UIApplicationWillEnterForegroundNotification object:nil];
}
//如何删除NSNotification的观察者
[[NSNotificationCenter defaultCenter] removeObserver:self];
答案 1 :(得分:2)
试试这个..
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(your animation method:) name:UIApplicationWillEnterForegroundNotification object:nil];
}