Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar not showing keyboard when tapped

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!

like image 214
Jing Avatar asked Sep 29 '14 17:09

Jing


1 Answers

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:

enter image description here]

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

like image 55
Aaron Avatar answered Oct 27 '22 19:10

Aaron