开发者

Forcing a background application to terminate in iOS simulator

开发者 https://www.devze.com 2023-04-04 10:52 出处:网络
In iOS 4 applications go to the background instead of terminating. For this reason I have to register for:

In iOS 4 applications go to the background instead of terminating. For this reason I have to register for:

[[NSNotificationCenter defaultCenter] addObserver:self
                                      selector:@selector(appWillTerminate:)
                                      name:UIAp开发者_开发知识库plicationWillResignActiveNotification
                                      object:[UIApplication sharedApplication]];

Instead of UIApplicationWillTerminateNotification.

But what happens if I want to test my UIApplicationWillTerminateNotification. How can I test it in the simulator?


If you want to test the reception of such a notification, add following key to your Info.plist file: Application does not run in background and set it to YES. The internal name is <key>UIApplicationExitsOnSuspend</key>.

This will tell iOS and the simulator, that your application wants to terminate rather than being sent to background when the home button is pressed. In this case, the UIApplicationWillTerminateNotification is sent.

For testing, this should suffice.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消