强制后台应用程序终止在iOS模拟器
在iOS 4应用程序转到背景而不是终止。 为此,我必须注册:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
而不是UIApplicationWillTerminateNotification。
但是如果我想testing我的UIApplicationWillTerminateNotification会发生什么。 我怎样才能在模拟器中testing它?
如果你想testing这样的通知的接收,添加以下关键到你的Info.plist文件: Application does not run in background
并将其设置为YES。 内部名称是<key>UIApplicationExitsOnSuspend</key>
。
这将告诉iOS和模拟器,您的应用程序想要终止,而不是被按下主页button时发送到后台。 在这种情况下,将发送UIApplicationWillTerminateNotification
。
为了testing,这应该就足够了。
希望这可以帮助。