What happens to an iPhone app when iPhone goes into stand-by mode?

后端 未结 6 816
忘掉有多难
忘掉有多难 2020-12-02 07:21

My app uses NSTimer and it appears that NSTimer doesn\'t fire when the iPhone goes into the stand-by mode (either by pressing the hardware button or by the idle timer).

6条回答
  •  死守一世寂寞
    2020-12-02 07:49

    See Application Interruptions in the iPhone OS Programming Guide, especially the applicationWillResignActive and applicationDidBecomeActive events. (The whole guide is certainly worth reading.) When You ignore the events, the timer seems to go on for a while and then stops. Sounds logical, the application could easily drain the battery if kept running. And what exactly happens to the application? I guess it simply does not get any CPU time – it freezes and only thaws when You turn the machine back “on.”

提交回复
热议问题