gpt4 book ai didi

当键盘打开时 View 更改后出现带有白色文本的 ios 黑色键盘

转载 作者:可可西里 更新时间:2023-11-01 04:43:26 25 4
gpt4 key购买 nike

我正在为我的标准 TextField 使用“深色”风格的键盘。这是用于登录文本字段或“忘记我的密码”文本字段,用户在其中输入一些信息,提交它,如果成功,它们将被发送到另一个 View ,通常由标准导航 Controller popViewControllerAanimated:。中间可能会出现一个 AlertView。

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

我尝试以各种方式在 popViewController 发生之前关闭原始键盘,但它似乎没有帮助。如果 AlertView 出现在两者之间,我将 popViewController 绑定(bind)到单击 AlertView 按钮时的委托(delegate)操作。键盘通常不会消失得足够快,无法在按下之前离开。延迟对它没有帮助。

编辑:alertview 似乎是这里的罪魁祸首,以某种方式干扰了流行音乐和键盘。

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

我怎样才能避免这种黑/白键盘?

enter image description here

最佳答案

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

关于当键盘打开时 View 更改后出现带有白色文本的 ios 黑色键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36230477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com