UISearchBar在点击时不显示键盘(仅适用于Xcode 5.1、iOS 7)

UISearchBar在点击时不显示键盘(仅适用于Xcode 5.1、iOS 7),xcode,ios7,uisearchbar,xcode5.1,Xcode,Ios7,Uisearchbar,Xcode5.1,这是我的源代码 [search setFrame:CGRectMake(listView.frame.origin.x, listView.frame.origin.y + 2,215, 52)]; [search setPlaceholder:@"Search"]; search.barTintColor = [UIColor colorWithRed:230/255.0f green:230/255.0f blue:230/255.0f alpha:1.0f

这是我的源代码

[search setFrame:CGRectMake(listView.frame.origin.x, listView.frame.origin.y + 2,215, 52)];
        [search setPlaceholder:@"Search"];

        search.barTintColor = [UIColor colorWithRed:230/255.0f green:230/255.0f blue:230/255.0f alpha:1.0f];;
        [search setTranslucent:NO];
        search.delegate = self;
        [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor blackColor]];
        UITextField *txfSearchField = [search valueForKey:@"_searchField"];
        txfSearchField.backgroundColor = [UIColor whiteColor];
它在Xcode 5.0上与iOS 5,6,7协同工作

将xcode更新为5.1后,my uisearchview在iOS 7和iOS 7.1中不显示键盘,但在iOS 6和更早版本中,它可以工作

我不知道解决办法

你能给我一些解决办法吗


谢谢

我也有同样的问题。如果你正在使用故事板,我想这会对你有所帮助。下载这里给出的示例代码

  • 也可以查看以下链接

  • 有关UISearchBar的问题,请查看此答案

  • 如果希望以编程方式定义视图,请执行以下操作:


我使用了XIB,你对此做过任何实验吗?我后来将XIB改为故事板。有什么解决方案吗?