Quit app when pressing home (按主页时退出应用程序)
问题描述
我的测试,当我退出(通过按主页按钮)我的应用程序时,由于多任务处理功能,它仍然在后台运行".但是,我希望它在按下主页按钮时退出.这只发生在我身上吗?
I my testing, when I exit (by pressing the home button) my app, it still is "running" in the background, thanks to the multitasking feature. However, I would like it to quit when the home button is pressed. Is this only happening to me?
无论如何,我已将其追溯到应用委托中的 applicationWillResignActive 和
applicationDidBecomeActive
方法.这些被称为多任务处理,但是当我想终止时,应用程序退出活动".非常感谢有关此问题的任何指导!
Anyway, I have tracked it down to the applicationWillResignActive
and the applicationDidBecomeActive
methods in the app delegate. These get called for multitasking, but when I want to terminate, the app "resigns active." Any guidance on this issue is greatly appreciated!
推荐答案
您的应用程序可以选择退出多任务处理(请参阅 UIApplicationExitsOnSuspend 键到 Info.plist 并将其值设置为 YES.
Your application can opt out of multitasking (see the appropriate section in the iPhone Application Programming Guide) by adding the UIApplicationExitsOnSuspend
key to your Info.plist and setting its value to YES.
实际上,Apple 强烈建议您不要这样做,除非您有充分的理由这样做.
In practice, Apple strongly recommends you not do this unless you have a very good reason for this behavior.
这篇关于按主页时退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:按主页时退出应用程序


- URL编码Swift iOS 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- UITextView 内容插图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01