我正在通过以下方法中止我的 iOS 应用程序
-(void)cancelSelected
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil message:@"Are you sure you want to exit?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
alert = nil;
}
方法一:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
abort();
}
方法二:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
[NSException raise:@"Disagree terms and conditions." format:@"Quit, Cancel"];
}
我应该这样做以编程方式退出我的 iOS 应用程序吗?
这会吗abort()
方法导致拒绝我的应用程序?
Thanks!
See QA1561 https://developer.apple.com/library/ios/qa/qa1561/_index.html:
问:如何以编程方式退出 iOS 应用程序?
答:没有提供用于优雅终止 iOS 的 API
应用。
在 iOS 中,用户按下主页按钮即可关闭应用程序。应该
您的应用程序存在无法提供其功能的条件
预期功能,建议的方法是显示警报
指示问题性质和可能采取的措施的用户
用户可以采取 - 打开 WiFi、启用定位服务、
等。允许用户自行终止应用程序
审慎。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)