How can I programmatically pause an NSTimer?

前端 未结 15 1794
梦毁少年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:13

    From here:

    http://discussions.apple.com/thread.jspa?threadID=1811475&tstart=75

    "You can store the amount of time that has passed since the timer started... When the timer starts store the date in an NSDate variable. Then when the user switches... use the method timeIntervalSinceNow in the NSDate class to store how much time has passed... note that this will give a negative value for timeIntervalSinceNow. When the user returns use that value to set an appropriate timer.

    I don't think there's a way to pause and restart a timer. I faced a similar situation. "

提交回复
热议问题