我已经阅读了许多有关如何聚焦搜索栏以使键盘在打开搜索视图时出现的解决方案,而所有这些解决方案都是像这样的:
[searchBar becomeFirstResponder];
mine is
[self.searchDisplayController.searchBar becomeFirstResponder];
but I tried both.
我尝试了这个,我还加了一个
[self.searchDisplayController setActive:YES];
因为我正在使用SearchDisplayController,但到目前为止我能够得到的最佳结果是将光标放在搜索栏上,带有覆盖层的uitableview,但仍然没有键盘。
如果我运行模拟器,我可以用电脑的键盘在搜索栏上输入,但在iPhone上我什么也做不了。
如果您想查看我的代码:http://nopaste.info/39fcda4771.html,应该在viewDidLoad方法中执行聚焦。
再次感谢。