2

我是 ios 开发的新手。我正在实施 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"];
4

2 回答 2

3

试试这个...

- (void)viewWillAppear:(BOOL)animated
 {
   [super viewWillAppear:animated];

   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addAnimation:) name:UIApplicationWillEnterForegroundNotification object:nil];

}

//如何为 NSNotification 移除一个观察者

  [[NSNotificationCenter defaultCenter] removeObserver:self];
于 2013-06-18T13:22:32.263 回答
2

试试这个..

 - (void)viewWillAppear:(BOOL)animated
 {
      [super viewWillAppear:animated];

  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(your   animation method:) name:UIApplicationWillEnterForegroundNotification object:nil];
 }
于 2013-06-17T13:58:30.290 回答