iOS的警告用法示例

iOS的警告用法示例 (UIActionSheet不让用之后,iOS8.3以后)

UIAlertController

 UIAlertController *VC = [UIAlertController alertControllerWithTitle:@"是否取消?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction *loginOutAction = [UIAlertAction actionWithTitle:@"注销" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
     // 点击注销按钮会做一些事
    [self.navigationController popViewControllerAnimated:YES];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    // 把按钮添加进controller
    [VC addAction:loginOutAction];
    [VC addAction:cancelAction];
    // 让警告显示出来
    [self presentViewController:VC animated:YES completion:nil];
// 显示在中间的alert(警告)
   UIAlertView *ok = [[UIAlertView alloc] initWithTitle:@"是否取消" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"注销", nil];
   [ok show];

你可能感兴趣的:(iOS的警告用法示例)