开发者

Maintain state of ipad/iphone application while running next time

开发者 https://www.devze.com 2023-01-29 06:31 出处:网络
Suppose i am running my iphone/ipad application my mistake i pressed home key and again i am running my application it started as usual to i don开发者_JAVA技巧\'t want to it started as usual i want to

Suppose i am running my iphone/ipad application my mistake i pressed home key and again i am running my application it started as usual to i don开发者_JAVA技巧't want to it started as usual i want to it start from the state where i was before pressing home key.

**In short it should be maintain the state of application while i am running next time.


in the function - (void)applicationDidEnterBackground:(UIApplication *)application inside your application delegate .m file, be sure that you don't call the exit function. when the home button is pressed, anything in this function will be ran.

- (void)applicationDidEnterBackground:(UIApplication *)application {
    //do nothing
}


This behaviour is default as of iphone 4.1 and ipad 4.2. YOu actually have to specifically stop it if you didn't want it. What version are you building for?

If it is the latest build, then like what binnnyb said, ahve a look in applicationDidEnterBackground and applicationWillResignActive for functions that will crash or end your app.

Also exit(); is not app store safe.


Implement - (void)applicationWillResignActive: in your NSApplicationDelegate to save your application state. You can then reload the saved state at startup.

0

精彩评论

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

关注公众号