问题
i wrote an application on the Xcode 4.2 using iOS SDK 5.0.
i have set the UIApplicationexitonsuspend in the info.plist to YES but when i double press the home button, the application is still in the multitasking bar.
i have deleted the app from my iPhone 4s and resend it again from Xcode but still the exit on suspend does not work. application still lingers on multitasking tab.
回答1:
The fact that your app icon is shown in the "multitask tab" does not mean that your app is still there.
The "multitask tab" simply shows a list of all the apps that you have run.
A simple way to assess if an app is launched anew when you touch it, is by doing the following steps:
launch your app;
close it by pressing the home button;
relaunch the app and inspect the image that it shows on startup. If this image is your "Default.png" image, then the app was launched anew. If you find your app in the state you left it, then the app was simply made active again (i.e., it was in the background).
A more advanced way to see what happens when you launch your app is put an NSLog
trace in your app delegate methods:
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
If you will see the traces printed out, then it means that the app was not quit on suspend.
Conversely, you could put a trace in:
- (void)applicationWillTerminate:(UIApplication *)application {
}
if it is called when you press the home button, then the app does not enter the background state, rather it quits.
回答2:
If you want that your app will not run in background mode. Do the following:- Open your application info.plist and then add another attribute it it:- "Application does not run in background mode" and make sure that check box is checked for this attribute. Now save , rebuild and run your app again. By doing this your app will not run in background mode.
回答3:
"Application does not run in background mode" and "UIApplicationexitonsuspend " are the same key
来源:https://stackoverflow.com/questions/8637111/application-still-running-in-background-xcode-4-2-ios-5