zoukankan      html  css  js  c++  java
  • UIAlertControlle的基本用法

     使用UIAlertController需要三步

    1、实例化alert:alertControllerWithTitle

    2、实例化按钮:actionWithTitle

    3、显示alertController:presentViewController

    下面是实现上面三步的简单代码

    //实例化alert:alertControllerWithTitle

        UIAlertController *alert= [UIAlertController alertControllerWithTitle:@"提示" message:@"请输入账号和密码" preferredStyle:UIAlertControllerStyleAlert];

        //实例化按钮actionWithTitle

        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) {

            NSLog(@"%@",[alert.textFields.firstObject text]);

        }]];

        //实例化按钮actionWithTitle

        [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];

        //添加文本框

        [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {

            textField.text=self.title;

        }];

        [alert addTextFieldWithConfigurationHandler:^(UITextField * textField) {

            //密文显示

            textField.secureTextEntry=YES;

        }];

        //显示alert

        [self presentViewController:alert animated:YES completion:nil];

    这是代码实现的结果

  • 相关阅读:
    使用android-ndk官方ndkbuild例子
    小米8如何root
    Ubuntu点击dash home就崩溃
    Python自定义排序
    adb命令
    sqoop数据导出导入命令
    Docker命令详解
    如何输出第二列相同的行
    如何使用Xmanager及VNC登录远程桌面
    搭建GoldenGate的单向复制环境
  • 原文地址:https://www.cnblogs.com/layios/p/5263678.html
Copyright © 2011-2022 走看看