Forcing the iPhone app to close when the Home button is pressed (on iOS4)

I do not want my application to switch to the "taskbar" when I click the "Home" button. That is why I would like it to close on the main press. I added this entry to the info.plist file, but this does not change the behavior:

the application does not work in the background

(and I checked the box ...)

I rebuilt the entire application both in debug mode and in release mode, but not at all. I heard about another key that should be added to info.plist, but I cannot add it through Xcode:

UIApplicationExitsOnSuspend

What is the right way to do this?

Hi,

Franz

+6
ios objective-c iphone background
source share
3 answers

In iOS 4, multitasking is enabled in Xcode projects by default. This prevents calling the applicationWillTerminate method. If you do not want to support multitasking, put the UIApplicationExitsOnSuspend in the MyAppName-Info.plist file and check the box. If you want to support it, put any code in the delegate method of applicationDidEnterBackground that you want to execute before the application enters an inactive state.

+17
source share

What you do will really make the application run in the background, but you cannot stop it from switching to the multitasking panel. Unfortunately.

+1
source share

You can manually close the application after pressing the home button. When the home button is pressed, applicationDidEnterBackground is called. In this case, just write exit(0) and your application will exit(0) instantly.

+1
source share

All Articles