How can I programmatically pause an NSTimer?

前端 未结 15 1735
梦毁少年i
梦毁少年i 2020-11-27 13:06

I\'m using an NSTimer to do some rendering in an OpenGL based iPhone app. I have a modal dialog box that pops up and requests user input. While the user is providing input

15条回答
  •  眼角桃花
    2020-11-27 13:31

    If your fire time interval is tolerant, you can use CADisplayLink instead of NSTimer. Because CADisplayLink support -pause.

    displayLink = [[CADisplayLink displayLinkWithTarget:self selector:@selector(fireMethod:)];
    displayLink.frameInterval = approximateVaue;//CADisplayLink's frame rate is 60 fps.
        [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    
    //pause
    [displayLink pause];
    

提交回复
热议问题