强制后台应用程序在iOS模拟器中终止 [英] Forcing a background application to terminate in iOS simulator

查看:264
本文介绍了强制后台应用程序在iOS模拟器中终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 4应用程序中转到后台而不是终止。出于这个原因,我必须注册:

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:UIApplicationWillResignActiveNotification
                                      object:[UIApplication sharedApplication]];

而不是UIApplicationWillTerminateNotification。

Instead of UIApplicationWillTerminateNotification.

但是如果我想测试我的UIApplicationWillTerminateNotification会发生。如何在模拟器中测试它?

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

推荐答案

如果您想测试接收此类通知,请添加以下密钥:您的Info.plist文件:应用程序不在后台运行并将其设置为YES。内部名称为< key> UIApplicationExitsOnSuspend< / key>

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>.

这将告诉iOS和模拟器,您的应用程序想要终止而不是在按下主页按钮时发送到后台。在这种情况下,会发送 UIApplicationWillTerminateNotification

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.

希望这有帮助。

这篇关于强制后台应用程序在iOS模拟器中终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆