我已经阅读了很多关于如何在打开搜索视图时聚焦搜索栏以使键盘出现的解决方案,所有这些都是这样的
[searchBar becomeFirstResponder];
mine is
[self.searchDisplayController.searchBar becomeFirstResponder];
but I tried both.
现在,我尝试了这个,并且我还添加了一个
[self.searchDisplayController setActive:YES];
因为我使用的是 UISearchDisplayController,但到目前为止,我能得到的最好结果是将光标放在搜索栏上,在其上覆盖了 uitableview,但仍然没有键盘。
如果我运行模拟器,我可以用电脑键盘在搜索栏上输入内容,但在 iPhone 上我什么也做不了。
如果你想看看我的代码:http://nopaste.info/39fcda4771.html http://nopaste.info/39fcda4771.html焦点应该在 viewDidLoad 方法中执行
再次感谢。
我在 textFieldDidBeginEditing:(UITextField *)textField 委托方法上显示搜索栏。
键盘没有显示。因此,首先将 textField 作为第一个响应者。
IE。
[textField resignFirstResponder];
然后延迟调用方法
[self performSelector:@selector(callSearchBar) withObject:NULL afterDelay:0.2];
Where
-(void)callSearchBar{
[self.searchDisplayController setActive: YES animated: YES];
self.searchDisplayController.searchBar.hidden = NO;
[self.searchDisplayController.searchBar becomeFirstResponder];
}
It works
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)