开发者

CADisplayLink fires one additional time after stopping it

Everything was OK, until yesterday when my app started to behave weirdly. It works OK on simulator but on iPhone4 it performs one additional cycle even after stopping it. Here's my initializer that creates a new CADisplayLink timer or resumes existing one:

-(void)initializeTimer{
  if (self.theTimer == nil) {  
    self.theTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(gameLoop)];
    self.theTimer.frameInterval = 2;
    [self.theTimer addToRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode];
  } else {
    self.theTimer.paused = NO;
  }

}

I need to stop and resume the timer quite frequently, so I'm stopping the timer with pause property:

self.theTimer.paused = YES;

Then I'm calling i开发者_JS百科nitializer that resumes it (self.theTimer.pause = NO). As said, it performs one additional call to selector method. Very strange, I had this app working with no CADisplayLink problems more than a month. I didn't do any updates to iPhone recently. In addition, systems sounds stopped to play at the same moment but AVAudioPlayer objects still work. As I said both timer and sounds works perfectly on simulator but I want to find out what causes a problem on iPhone. All stuff is done with pure UIKit. Any ideas where to start?


Very weird. I just removed my app from test iPhone 4, compiled and ran again on it, and the problem disappeared. I know that I didn't spotted the problem but after a lot of trial time I gave up. However, after that, I have submitted my app to the app store and it was approved. Hope that was some kind of debugging issue instead of being a real problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜