我通過以下方法退出的iOS應用程序編程與UIAlertView中
-(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;
}
方法1中止我的iOS應用:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
abort();
}
方法2:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
[NSException raise:@"Disagree terms and conditions." format:@"Quit, Cancel"];
}
我應該這樣做以編程方式退出我的iOS應用程序?
這個abort()
方法會拒絕我的應用程序嗎?
謝謝!
是的,它可能會 –
https://developer.apple.com/library/ios/qa/qa1561/_index.html – rdurand
這將是50- 50。他們可能會也可能不會注意到它。其他方式是 - 讓它退出,做一些意想不到的事情 - 在'nil'上調用方法...這樣,應用程序就會崩潰並退出。 – Michal