简体   繁体   English

点按时UISearchBar不显示键盘

[英]UISearchBar not showing keyboard when tapped

I programmatically added a UISearchBar in the view, did some initial setup. 我以编程方式在视图中添加了一个UISearchBar,做了一些初始设置。 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! 谢谢!

If you're using Xcode 6.0.1, its possible that your hardware keyboard is taking over for the simulator keyboard. 如果您使用的是Xcode 6.0.1,则可能是您的硬件键盘正在接管模拟器键盘。 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: 另外,这篇文章解释了如何回到Xcode 5.1.1中键盘的行为:

In Xcode 6, how do I use the hardware keyboard but display the software keyboard in the iOS simulator 在Xcode 6中,如何使用硬件键盘但在iOS模拟器中显示软件键盘

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM