zoukankan      html  css  js  c++  java
  • 【iOS】UIAlertController 弹出框

    UIAlertView 虽然还能用,但已经废弃了。因此以后尽量用 UIAlertController。示例代码如下:

        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"
                                                                       message:@"确定要删除?"
                                                                preferredStyle:UIAlertControllerStyleAlert];
    
        [alert addAction:[UIAlertAction actionWithTitle:@"取消"
                                                  style:UIAlertActionStyleCancel
                                                handler:^(UIAlertAction *action){NSLog(@"点击了取消按钮");}]];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定"
                                                  style:UIAlertActionStyleDefault
                                                handler:^(UIAlertAction *action){NSLog(@"点击了确定按钮");}]];    
        [self presentViewController:alert animated:YES completion:nil];

    可以添加弹出框选项,并触发相应的点击事件。

    效果图:

    日志:

    还可以添加更多点击选项,如图所示:

    PS: 按照添加的顺序,从下到上显示。

    参考:http://www.jianshu.com/p/8025e598e9fd

  • 相关阅读:
    02-cocoapods的安装和使用
    01-唐巧之cocoapods
    class0513(html)
    程序集
    c#面向对象
    html
    dom
    Javascript
    Jquery
    ado.net
  • 原文地址:https://www.cnblogs.com/jaxer/p/5581211.html
Copyright © 2011-2022 走看看