iOS-使用按钮杀死应用程序? [英] iOS - kill the app with a button?

查看:490
本文介绍了iOS-使用按钮杀死应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以运行一段时间的应用程序,但是每天都需要重置,因为它的生命周期与大多数其他应用程序有所不同.似乎最简单的方法是杀死该应用程序,然后重新启动它.

I have an app that runs for a while, but needs to be reset every day, because it's lifecycle is a bit different than most other apps. It seems that the easiest way to do this is to kill the app and re-launch it.

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

I found a solution that kills the app when the home button is tapped:

在应用程序的Info.plist中,添加一个布尔键 UIApplicationExitsOnSuspend的值为YES

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

这不是我想要做的.我需要给用户一个选项,以便在使用前取消/重置该应用程序.我当然可以要求用户双击Home键并长按> x杀死该应用程序.但这对于某些用户来说太复杂了.

This is not something that I want to do. I need to give the user an option to kill/reset the app before it is used. I can certainly ask the user to double tap the home key and kill the app with a long press>x. Yet this is too complex for some users.

另一种简单的解决方案是让按钮执行令人崩溃的操作,例如除以0,尽管我不确定应用商店是否会因为所有用户每天崩溃"而对我的应用进行惩罚.

Another simple solution would be to have a button do something crashworthy, like divide by 0, although I'm not sure if the app store would penalize my app for "crashing" every single day for all users.

有没有人找到向iPhone应用程序添加退出"按钮的方法?在android中,我可以执行system.exit(0),该方法可以正常工作.什么是iPhone替代品?

推荐答案

iOS人机界面指南说-

iOS Human Interface Guide says - Don’t Quit Programmatically

永远不要以编程方式退出iOS应用程序,因为人们倾向于 将此解释为崩溃.但是,如果外部环境阻止 您的应用程序无法按预期运行,您需要告诉您的 用户了解情况,并说明他们可以采取的措施. 根据应用程序故障的严重程度,您有两个 选择. ...

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是正常代码),但是Apple不喜欢这种方法,因此该应用程序将在审查中被拒绝.


exit(0); can terminate the application (0 is a normal code), but Apple don't like this approach, and the application would be rejected in review.

这篇关于iOS-使用按钮杀死应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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