how can i close or minimize my app from code like when i push home b开发者_StackOverflowutton?
exit(0);
will close your app.
Its not recommended though.
You don't have to do anything, it'll be done by the framework
To minimize your app using an approved API, launch another app, for instance Safari, using a registered URL.
You can use exit(0)
but your application will be rejected if you submit it to the App Store. This is because the guidelines state that a user should only be able to exit the application by pressing the home button.
EDIT: This is pretty much a duplicate of this. Much more discussion here...
Ok, I guess I got your question.
Yes that is correct you don't need any special code when pressing home button to exit app. And yes that is correct that exit (0) can make it from the code.
- (void)vypni { exit(0); }
What is not correct that your app will be reject. I use exit (0) in my code and the app with it is available on the app store now. I guess if you take good management around what should be done (disable timers, etc) it can be used.
[[UIApplication sharedApplication] terminateWithSuccess];
Compiler will give warning. you should ignore it. This will work.
精彩评论