iOS UIAlertController使用方法如何使用

来源:互联网 发布:ps3无限验证游戏数据 编辑:程序博客网 时间:2024/05/17 05:17

UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"密码"message:nilpreferredStyle:UIAlertControllerStyleAlert];


[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {

                // 可以在这里对textfield进行定制,例如改变背景色

textField.placeholder = @"请输入私人直播室的密码";

     }];


 UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"  style:UIAlertActionStyleCancelhandler:^(UIAlertAction *action) {

               NSLog(@"The \"Okay/Cancel\" alert's cancel action occured.");

            }];


            UIAlertAction *otherAction = [UIAlertActionactionWithTitle:@"OK"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {

                NSLog(@"The \"Okay/Cancel\" alert's other action occured.");

            }];


            // Add the actions.

            [alertController addAction:cancelAction];

            [alertController addAction:otherAction];

            

            [selfpresentViewController:alertController animated:YEScompletion:nil];

0 0