On iOS 4, multitasking is enabled in Xcode projects by default. This prevents theapplicationWillTerminate
method from being called. If you do not want to support multitasking, placeUIApplicationExitsOnSuspend
in your MyAppName-Info.plist file and check the checkbox. If you do want to support it, place any code in theapplicationDidEnterBackground
delegate method that you want to execute before the application enters an inactive state.
在IOS4中,Xcode项目的缺省属性是 多任务支持。如果你不想支持多任务,那么就在 MyAppName-Info.plist 文件中放置 Application does not run in background 属性,并且设置成YES。