小编bea*_*rob的帖子

iOS - 隐藏在键盘下的UIAlertController

我有一个UIAlertController从提出UIViewController这是在推UINavigationController作为最后UIViewController.这里面UIAlertViewController有一个UITextField.

我的问题是,当我选择UITextField键盘显示,但UIAlertViewController保持居中,并部分隐藏在键盘下.

我的代码看起来像这样:

UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Enter Your PIN" message:@"Please enter your PIN!" preferredStyle:UIAlertControllerStyleAlert];

[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        [textField setSecureTextEntry:YES];
    }];

UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"Confirm"
                                                       style:UIAlertActionStyleDefault
                                                     handler:^(UIAlertAction * _Nonnull action) {  }];


UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
                                                           style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * _Nonnull action) {
                                                         }];
[alert addAction:okAction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

Screnshot隐藏的UIAllertController

keyboard objective-c ios uialertcontroller

7
推荐指数
2
解决办法
1558
查看次数

标签 统计

ios ×1

keyboard ×1

objective-c ×1

uialertcontroller ×1