键盘打开后视图更改后出现带有白色文本的ios黑色键盘

Mir*_*iro 5 keyboard ios alertview

我正在为我的标准TextField使用"黑暗"式键盘.这是用于登录文本字段,或"忘记我的密码"文本字段,用户在其中输入一些信息,提交它,如果成功,则将它们发送到另一个视图,通常由标准导航控制器popViewControllerAanimated:.AlertView可能出现在两者之间.

我看到很多问题是键盘是打开的,正常的"深色"灰色,然后用户点击提交,可能会出现一个警报视图,当解雇时,视图转移到下一个屏幕以前的键盘关闭屏幕.在新屏幕上,另一个默认样式键盘可能会或可能不会向上滑动然后消失(甚至没有文本域聚焦!).然后,当点击另一个文本字段,或返回上一个视图并单击文本字段时,这个带有白键的黑色键盘会出现错误.它会继续出现在文本字段中,直到某些内容能够在几次单击后将其恢复为正常的深灰色.

我试图在popViewController发生之前以各种方式解除原始键盘,但它似乎没有帮助.如果AlertView出现在中间,我在单击AlertView按钮时将popViewController绑定到委托操作.键盘通常不会快速消失,在推动前离开.延迟对它没有帮助.

编辑:警报视图似乎是一个明确的罪魁祸首,以某种方式干扰弹出和键盘.

-(BOOL) textFieldShouldReturn:(UITextField *)textField{
    [textfield resignFirstResponder];
    [self.view endEditing:YES];
    return YES;
}

-(IBAction)submitRequest {
    [textfield resignFirstResponder];
    [self.view endEditing:YES];

    // make API call, if call succeeds run this block {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"..."
                                                message:@"..."
                                               delegate:delegate
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil, nil];
          dispatch_async(dispatch_get_main_queue(), ^{
            [alert show];
          });         
    // }
}

// delegate after alert OK is pressed
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  [self.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

如何避免使用黑/白键盘?

在此输入图像描述

jbc*_*iya 3

Try using the below code. It works fine for iOS 8 and below version

    if (IS_OS_8_OR_LATER) {
            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction *cancelAction = [UIAlertAction
                                       actionWithTitle:B_title
                                       style:UIAlertActionStyleCancel
                                       handler:^(UIAlertAction *action)
                                       {
                                           [self.navigationController popViewControllerAnimated:YES];

                                       }];
        [alertVC addAction:cancelAction];
        [self presentViewController:alertVC animated:YES completion:nil];
        }
        else{
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
        }
}
Run Code Online (Sandbox Code Playgroud)