how can i close or minimize my app from code like when i push home button?
-
Could you clarify your question: do you mean that you do not want to enter the background state (iOS 4) and instead would like to quit your app when the user taps the home button? – Felix Lamouroux Nov 03 '10 at 14:29
-
1possible duplicate of [Proper way to exit iPhone application?](http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application) – Brad Larson Nov 03 '10 at 15:19
6 Answers
To minimize your app using an approved API, launch another app, for instance Safari, using a registered URL.

- 70,107
- 14
- 90
- 153
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...
-
-
It's in the guidelines. I don't think Apple are big fans of going against it! – ingh.am Nov 03 '10 at 12:19
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.

- 4,973
- 5
- 32
- 57
[[UIApplication sharedApplication] terminateWithSuccess];
Compiler will give warning. you should ignore it. This will work.

- 1,113
- 1
- 9
- 26