iOS alertController自带的输入框

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"请输入支付密码" preferredStyle:UIAlertControllerStyleAlert];

    //增加取消按钮;

    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

 

    }]];

 

    //增加确定按钮;

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

        //获取第1个输入框;

        

        UITextField *userNameTextField = alertController.textFields.firstObject;

        NSLog(@"支付密码 = %@",userNameTextField.text);

    }]];

    

    //定义第一个输入框;

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

        textField.placeholder = @"请输入支付密码";

        textField.secureTextEntry = YES;

    }];

    

    [self presentViewController:alertController animated:true completion:nil];

 

posted @ 2017-01-20 14:31  琼极一生  阅读(5482)  评论(0编辑  收藏  举报