问题描述
我以编程方式在视图中添加了一个UISearchBar,做了一些初始设置。但是,当我点击搜索栏时,键盘没有显示出来。我在这个网站上查了一些问题,似乎没有人能为我工作。
I programmatically added a UISearchBar in the view, did some initial setup. However, when I tap the search bar, the keyboard is not showing up. I looked up some question on this site, and none seems working for me.
以下是我用来设置搜索栏的代码片段
Here is the code snippets I used to setup the search bar
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(origin.x,origin.y,width,height)];
self.searchBar.searchBarStyle = UISearchBarStyleDefault;
self.searchBar.translucent = YES;
self.searchBar.barTintColor = [UIColor whiteColor];
...
[self.searchBar setDelegate:self];
[self.view addSubView:self.searchBar];
有关修复此问题的任何建议吗?谢谢!
Any suggestions on fix this? Thanks!
推荐答案
如果您使用的是Xcode 6.0.1,您的硬件键盘可能会接管模拟器键盘。运行模拟器时,请确保未选中此选项。当您点按搜索栏时,这会触发模拟器键盘:
If you're using Xcode 6.0.1, its possible that your hardware keyboard is taking over for the simulator keyboard. When running the simulator, make sure this option is unchecked. This should trigger the simulator keyboard when you tap in your Search Bar:
]
此外,这篇文章还解释了如何回到Xcode 5.1.1中键盘的行为:
Also, this post explains how to get back to the behavior of the keyboard in Xcode 5.1.1:
这篇关于点击时UISearchBar不显示键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!