iPhone4, how to stop an application being suspended?
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.
精彩评论