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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM