如何使用objective-c代码退出iPhone应用程序?

时间:2013-02-27 11:27:48

标签: iphone objective-c

我需要退出应用程序而不使用home按钮。我调用exit(0)方法正常工作。 它是退出应用程序或任何问题的正确方法吗?。如果退出应用程序的任何其他方式? 。 请帮帮我..

3 个答案:

答案 0 :(得分:1)

<强> any another way to exit application?

添加Application does not run in background密钥并在应用程序plist文件中设置其值YES。当您的用户按下主页按钮时,应用程序将关闭。

答案 1 :(得分:0)

您可以使用abort();或引发NSException,这会导致应用程序崩溃。

以编程方式退出应用程序不是推荐的行为,您应该向用户显示警告,说明应用程序需要退出的原因,并告诉用户如何退出应用程序,以便它不会看起来你的应用程序有问题。

答案 2 :(得分:0)

iOS Human Interface Guidelines says Don't Quit Programmatically. we have seen many of apps that had calls to exit(0) previously.
    Apple provided the different stages to exit the app. For that they provided different methods. So by exit() code its not proper to exit the app since the app will get rejected by Apple.
    you can refer this Apple Doc at http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW27