UIAlertController使用

Posted dzq999

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UIAlertController使用相关的知识,希望对你有一定的参考价值。

    //1创建弹框控制器
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"亲,确定要滚吗?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    //2.1添加确定事件
    UIAlertAction *sureBtn = [UIAlertAction actionWithTitle:info style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        // 回到登录界面
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alertVc addAction:sureBtn];
    //2.2添加取消事件
    UIAlertAction *cancelBtn = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"---点击了取消按钮");
    }];
    [alertVc addAction:cancelBtn];
    //3展示控制器
    [self presentViewController:alertVc animated:YES completion:nil];

 

以上是关于UIAlertController使用的主要内容,如果未能解决你的问题,请参考以下文章

UIAlertController的popover变形

如何在 UIAlertController 上添加动态按钮?

多行 UIAlertController 消息

从第一个 UIAlertController 打开第二个 UIAlertController

将复选框列表添加到 UIAlertController

UIAlertController 下最顶层的 ViewController