gpt4 book ai didi

iphone - 如何在 UIAlertView 中制作文本字段 "become first responder"

转载 作者:可可西里 更新时间:2023-11-01 03:28:14 24 4
gpt4 key购买 nike

我在 UIAlertView 中有两个文本字段。我希望第二个成为第一响应者,这样用户就不必点击它。显示警报 View 后,我有以下代码:

[textField becomeFirstResponder];

唯一的问题是它不起作用。第一个文本字段中有打字机。有任何想法吗?感谢您的帮助。

最佳答案

我在尝试将焦点设置到 UIAlertView 中的密码字段时遇到了同样的问题(我正在预先填充用户名)。我不得不使用委托(delegate)方法:

- (void)didPresentAlertView:(UIAlertView *)alertView {
UITextField *textField = [alertView textFieldAtIndex:0];
[textField becomeFirstResponder];
}

如果我在 willPresentAlertView 上或在创建 alertView 时尝试它,它不起作用,仅在 didPresentAlertView 上起作用。我希望这会有所帮助。

关于iphone - 如何在 UIAlertView 中制作文本字段 "become first responder",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8646353/

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