【问题标题】:Taperecorder wheel animation is not working after the Home button is pressedTaperecorder 轮动画在按下 Home 按钮后不起作用
【发布时间】:2013-06-15 12:28:36
【问题描述】:

我是 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"];

【问题讨论】:

  • 当我按下 iOS 设备上的主页按钮时,我的应用程序暂停(并且动画 - 以及几乎所有其他内容 - 停止)。大多数 iOS 应用程序不应该这样吗?
  • 那么,您对 iPhone/iPad 的期望是什么?

标签: ios objective-c xcode4.2 cabasicanimation


【解决方案1】:

试试这个...

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

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

}

//如何为 NSNotification 移除观察者

  [[NSNotificationCenter defaultCenter] removeObserver:self];

【讨论】:

    【解决方案2】:

    试试这个..

     - (void)viewWillAppear:(BOOL)animated
     {
          [super viewWillAppear:animated];
    
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(your   animation method:) name:UIApplicationWillEnterForegroundNotification object:nil];
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      相关资源
      最近更新 更多