问题
how can i close or minimize my app from code like when i push home button?
回答1:
exit(0);
will close your app.
Its not recommended though.
回答2:
You don't have to do anything, it'll be done by the framework
回答3:
To minimize your app using an approved API, launch another app, for instance Safari, using a registered URL.
回答4:
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...
回答5:
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.
回答6:
[[UIApplication sharedApplication] terminateWithSuccess];
Compiler will give warning. you should ignore it. This will work.
来源:https://stackoverflow.com/questions/4086465/close-minimize-app-from-code