开发者

iPhone4, how to stop an application being suspended?

开发者 https://www.devze.com 2023-02-18 06:16 出处:网络
I am trying to test an application that needs to run over an extended period of time and to aid initial testing I am trying to find a way开发者_运维问答 to stop iOS moving the application to the backg

I am trying to test an application that needs to run over an extended period of time and to aid initial testing I am trying to find a way开发者_运维问答 to stop iOS moving the application to the background and suspending it. Ultimately I will add code to facilitate the use of multi-tasking but right now I just want to better test the core mechanics without iOS pushing it into the background all the time.


You can not prevent ios from suspending an app. The home button will close/resign active the application and even if you request for a background task apple can kill your app at any time as it sees necessary (More than likely for memory reasons).


As long as you, the user, don't stop this app, launch another app, or lock the device:

[[UIApplication sharedApplication] setIdleTimerDisabled: YES];

might keep your app running in the foreground. Don't forget to re-enable the idle timer, or this could keep the device running until the battery is dead.

0

精彩评论

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