gpt4 book ai didi

objective-c - 当我将 UIAlertView 中的 UITextField 设为第一响应者时,为什么键盘不显示?

转载 作者:行者123 更新时间:2023-11-29 11:21:47 26 4
gpt4 key购买 nike

我有一个弹出的警报 View ,里面有一个文本字段,我希望文本字段成为第一响应者并立即显示键盘。

当我使用 [summaryField becomeFirstResponder] 时;我在文本字段中看到一个闪烁的光标,但键盘没有弹出。但是,如果我不将文本设置为第一响应者,而是在显示警报时仅在其中单击,键盘就会弹出。

关于文本字段如何在不显示键盘的情况下成为第一响应者的任何想法?我猜想这与作为 subview 添加到警报 View 的文本字段有关,但我不知道到底是什么问题。我的代码如下,没有调用“becomeFirstResponder”。

UIAlertView *titleAlert = [[UIAlertView alloc] initWithTitle:@"Enter title" message:@" "     
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
summaryField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[summaryField setBackgroundColor:[UIColor whiteColor]];
[titleAlert addSubview:summaryField];
[titleAlert show];
[titleAlert release];
[summaryField release];

最佳答案

UIAlertViewDelegate willPresentAlertView: 方法中尝试 [textField becomeFirstResponder]

关于objective-c - 当我将 UIAlertView 中的 UITextField 设为第一响应者时,为什么键盘不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6698086/

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