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设备管理器
    Android中读取手机联系人
    PopupWindow
    Activity之间数据的传递
    wpa_supplicant
    nandflash之基本特性
    NAND NOR Flash 和MTD
    mtd-util
    linux 常用命令
    minizip -基于zlib开源代码库
  • 原文地址:https://www.cnblogs.com/layios/p/5263678.html
Copyright © 2011-2022 走看看