在不触摸UISearchBar
的情况下,我可以在viewWillAppear
方法调用时显示键盘吗?
在不触摸UISearchBar
的情况下,我可以在viewWillAppear
方法调用时显示键盘吗?
[mySearchBar becomeFirstResponder];
解决方案:
在成为第一响应者之前,不要使用 [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];
});
});
}