如何在不触摸UISearchbar的情况下显示键盘?

时间:2011-09-03 11:48:33

标签: iphone ios keyboard uisearchbar

我可以在UISearchbar方法调用上显示viewWillAppear的键盘,而无需触及UISearchbar吗?

2 个答案:

答案 0 :(得分:18)

[mySearchBar becomeFirstResponder];

答案 1 :(得分:1)

工作解决方案: -

在使用firstFirstResponder之前不要使用[self.searchController setActive:YES]。

- (void)viewDidAppear:(BOOL)animated {
         [super viewDidAppear:animated];
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
       //[self.searchController setActive:YES];
         [self.searchController.searchBar becomeFirstResponder];
       });
   });
}