iOS - 用一个按钮杀死应用程序?

标签 ios objective-c iphone exit

我有一个应用程序运行了一段时间,但每天都需要重置,因为它的生命周期与大多数其他应用程序有点不同。似乎最简单的方法是终止应用程序并重新启动它。

我找到了一个在点击主页按钮时终止应用程序的解决方案:

In your application's Info.plist, add a boolean key UIApplicationExitsOnSuspend with the value YES

这不是我想做的事。我需要给用户一个选项,让用户在使用应用程序之前终止/重置应用程序。我当然可以要求用户双击主页键并长按 >x 终止应用程序。然而,这对于某些用户来说太复杂了。

另一个简单的解决方案是让一个按钮做一些防崩溃的事情,比如除以 0,尽管我不确定应用商店是否会因为我的应用每天都为所有用户“崩溃”而惩罚我。

有没有人找到向 iPhone 应用程序添加“退出”按钮的方法?在 android 中,我可以执行 system.exit(0),这很有效。 iPhone 的替代品是什么?

最佳答案

iOS 人机界面指南说 - Don’t Quit Programmatically

Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your application from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the application malfunction is, you have two choices. ...


exit(0);可以终止申请(0为普通代码),但苹果不喜欢这种做法,申请会被review拒绝。

关于iOS - 用一个按钮杀死应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8195923/

相关文章:

ios - 是否可以降低状态栏的高度?

ios - 在 iOS 设备上本地解析和存储对象

iphone - 在构建表格时如何在 UITableViewController 中显示 View ?

iphone - 如何确保不显示没有行的部分

ios - swift3 中的表格 View 单元格

ios - FileManager 找不到音频文件

ios - 可以在没有 DEP 的情况下强制 iOS 更新 OTA 吗?

ios - 如何格式化 iOS 7 UIPickerView 以仅显示 3 个选择? IE。主动选择上面一个和下面一个?

ios - 两个日期之间经过的天数总是相差一天

objective-c - Mac OS X 系统中按 id 列出的 bundle 列表