alertcontroll带textField的实用用法

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入免审密码" message:@"无密码直接'确定'提交审核" preferredStyle:UIAlertControllerStyleAlert];

    __weak typeof(alert) wAlert = alert;

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

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

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

    }]];

    [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {

 

    }];

    // 由于它是一个控制器 直接modal出来就好了

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

posted @ 2017-02-06 15:43  二十几岁的某一天  阅读(242)  评论(0编辑  收藏  举报