UISearchBar not showing keyboard when tapped

余生颓废 提交于 2019-12-10 02:22:07

问题


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!


回答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:

]

Also, this post explains how to get back to the behavior of the keyboard in Xcode 5.1.1:

In Xcode 6, how do I use the hardware keyboard but display the software keyboard in the iOS simulator



来源:https://stackoverflow.com/questions/26105377/uisearchbar-not-showing-keyboard-when-tapped

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!