Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close an application programmatically when the user taps on a button

I need to close the application whenever user taps on the button(i need to keep IBAction for closing the app).Like in games menu we have exit button when we tap on it we come out from the game.Same thing i need.How can i do this .Thanks in advance

like image 461
iphoneStruggler Avatar asked Oct 26 '10 06:10

iphoneStruggler


2 Answers

Please see: How do I programmatically quit my iPhone application?

WARNING: It is possible to quit the application by calling exit. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen. Such usage provides a negative experience and is strongly discouraged.

like image 200
Chris Gummer Avatar answered Oct 03 '22 19:10

Chris Gummer


Instead of it, If you want your app to terminate when the user presses the home button, set the value of UIApplicationExitsOnSuspend to YES in your app's Info.plist file. If you do this, when the user taps the home button the applicationWillTerminate: method of your app delegate will be called and then your application will terminate.

like image 25
Shreyash Mahajan Avatar answered Oct 03 '22 21:10

Shreyash Mahajan