iOS - kill the app with a button?

删除回忆录丶 提交于 2019-12-23 23:32:39

问题


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:

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

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.

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.

Has anyone found a way to add an "exit" button to an iPhone app? In android, I could do system.exit(0), which worked. What's the iPhone alternative?


回答1:


iOS Human Interface Guide says - 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); can terminate the application (0 is a normal code), but Apple don't like this approach, and the application would be rejected in review.



来源:https://stackoverflow.com/questions/8195923/ios-kill-the-app-with-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!