如何在Objective-C中关闭iPad应用程序?

Joh*_*ohn 3 iphone ipad

我想通过点击UIButton来关闭iPad应用程序.但是,我还没有在Apple文档中看到如何执行此操作.

需要做什么电话来关闭应用程序?

谢谢.

tas*_*oor 5

您可以调用exit(0)来终止应用程序.但Apple并不喜欢这样,因为这会给用户带来突然崩溃的感觉.如果您仍希望具有退出功能(具有潜在的拒绝风险),那么您还应该在执行退出之前向app app委托发送applicationWillTerminate消息(如果您有任何重要信息).


Yuc*_*ram 5

它说:

不要以编程方式退出

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

Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your app. It puts users in control, letting them decide whether they want to take corrective action and continue using your app or press the Home button and open a different app

If only some of your app's features are unavailable, display either a screen or an alert when people use the feature. Display the alert only when people try to access the feature that isn’t functioning.