gpt4 book ai didi

ios - 故障排除 becomeFirstResponder 不为某些用户显示键盘

转载 作者:技术小花猫 更新时间:2023-10-29 10:13:18 60 4
gpt4 key购买 nike

我得到了一个 TextView,它应该在按下按钮时显示,并让用户通过键盘输入文本。

- (IBAction) changeName {

changeNameBtn.hidden = YES;
backBtn.hidden = YES;

usernameLabel.hidden = NO;
inputTextField.hidden = NO;
[inputTextField becomeFirstResponder]; // to show keyboard
}

这对我们大多数人来说都很好。

但对于我的一些测试人员来说键盘不显示,在地理位置偏远的位置。如何解决这个问题?我们的设备出现不同行为的原因可能是什么?它对我和其他人都很好。我们都使用相同的设备(iPod、iOS 4.1 - 5.1)。

我尝试的第一件事没有用:

我猜 inputTextField 在 becomeFirstResponder 被触发之前确实以某种方式没有及时变得可见,所以我添加了 setNeedsDisplay 因为我认为这会强制更新。

[inputTextField setNeedsDisplay];
[inputTextField becomeFirstResponder];

第二个我试过的东西没有用:

if([inputTextField canBecomeFirstResponder]){
[inputTextField becomeFirstResponder];
}

第三个我尝试的是一种解决方法,要求不幸的用户按下该字段:

- (IBAction) inputTextFieldTouch {
[inputTextField becomeFirstResponder];
}

此解决方法有效,但必须有更好的方法。请告诉我我做错了什么! :) 以及如何在自己无法复制的情况下解决此类问题?

最佳答案

稍后我通过这行代码调用了 becomeFirstResponder:

[self.searchBar performSelector:@selector(becomeFirstResponder) 
withObject:nil
afterDelay:0.1f];

它对我有用。希望对您有所帮助。

关于ios - 故障排除 becomeFirstResponder 不为某些用户显示键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8476021/

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