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];

    这是代码实现的结果

  • 相关阅读:
    Mysql(11)_Mysql权限与安全
    Mysql(10)_存储过程与流程控制
    Java(43)_AWT事件处理挂关闭生效
    6.实现合同测试用例
    6.测试库优化
    5.案例回顾及编写测试用例
    4.测试案例实现代码库与测试用例V2.0
    3.测试案例实现代码库与测试用例
    markdown语法学习
    1.faker批量随机造数据
  • 原文地址:https://www.cnblogs.com/layios/p/5263678.html
Copyright © 2011-2022 走看看