Nat*_*jan -1 abort uialertview ios
我正在通过以下方法中止我的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;
}
Run Code Online (Sandbox Code Playgroud)
方法1:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
abort();
}
Run Code Online (Sandbox Code Playgroud)
方法2:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex)
[NSException raise:@"Disagree terms and conditions." format:@"Quit, Cancel"];
}
Run Code Online (Sandbox Code Playgroud)
我这样做是为了以编程方式退出我的iOS应用程序吗?
这种abort()方法会拒绝我的应用吗?
谢谢!
小智 6
是的,上面的代码将导致拒绝。在警报的确定按钮中使用此代码:
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17785 次 |
| 最近记录: |