单击按钮时退出应用程序 - iOS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14335848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
exit application when click button - iOS
提问by AVINASH KANNA
Possible Duplicate:
Exit application in iOS 4.0
可能的重复:
在 iOS 4.0 中退出应用程序
I have a AlertView which displays some text and an "OK" button. Is there any way to exit application when clicked on OK button?
我有一个 AlertView,它显示一些文本和一个“确定”按钮。单击“确定”按钮时,有没有办法退出应用程序?
回答by Larme
exit(X)
, where X is a number (according to the doc) should work.
But it is not recommended by Apple and won't be accepted by the AppStore.
Why? Because of these guidelines (one of my app got rejected):
exit(X)
,其中 X 是一个数字(根据文档)应该可以工作。但它不是苹果推荐的,也不会被 AppStore 接受。为什么?由于这些准则(我的一个应用程序被拒绝):
We found that your app includes a UI control for quitting the app. This is not in compliance with the iOS Human Interface Guidelines, as required by the App Store Review Guidelines.
Please refer to the attached screenshot/s for reference.
The iOS Human Interface Guidelines specify,
"Always Be Prepared to Stop iOS applications stop when people press the Home button to open a different application or use a device feature, such as the phone. In particular, people don't tap an application close button or select Quit from a menu. To provide a good stopping experience, an iOS application should:
Save user data as soon as possible and as often as reasonable because an exit or terminate notification can arrive at any time.
Save the current state when stopping, at the finest level of detail possible so that people don't lose their context when they start the application again. For example, if your app displays scrolling data, save the current scroll position."
> It would be appropriate to remove any mechanisms for quitting your app.
我们发现您的应用包含用于退出应用的 UI 控件。这不符合 App Store 指南要求的 iOS 人机界面指南。
请参阅随附的屏幕截图以供参考。
iOS人机界面指南规定,
“当人们按下主页按钮打开不同的应用程序或使用设备功能(例如手机)时,始终准备停止 iOS 应用程序停止。特别是,人们不会点击应用程序关闭按钮或从菜单中选择退出。为了提供良好的停止体验,iOS 应用程序应该:
尽快并尽可能合理地保存用户数据,因为退出或终止通知可以随时到达。
停止时保存当前状态,尽可能详细地保存当前状态,以便人们在再次启动应用程序时不会丢失上下文。例如,如果您的应用显示滚动数据,请保存当前滚动位置。”
> 删除任何退出应用程序的机制是合适的。
Plus, if you try to hide that function, it would be understood by the user as a crash.
另外,如果您尝试隐藏该功能,用户将理解为崩溃。
回答by Anoop Vaidya
You can use exit method to quit an ios app :
您可以使用 exit 方法退出 ios 应用程序:
exit(0);
You should say same alert message and ask him to quit
你应该说同样的警告信息并要求他退出
Another way is by using [[NSThread mainThread] exit]
另一种方法是使用 [[NSThread mainThread] exit]
However you should not do this way
但是你不应该这样做
According to Apple, your app should not terminate on its own. Since the user did not hit the Home button, any return to the Home screen gives the user the impression that your app crashed. This is confusing, non-standard behavior and should be avoided.
根据 Apple 的说法,您的应用不应自行终止。由于用户没有点击主页按钮,因此任何返回主页屏幕都会给用户留下您的应用程序崩溃的印象。这是令人困惑的、非标准的行为,应该避免。