[IOS]alertController自带的输入框

阅读更多

转自:https://www.cnblogs.com/LynnAIQ/p/6322783.html

 

 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;

    }];

 

你可能感兴趣的:(alertController)