Can I show the keyboard for UISearchbar
on viewWillAppear
method call without touching the UISearchbar
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
[mySearchBar becomeFirstResponder];
回答2:
Working Solution:-
Don't use [self.searchController setActive:YES] before becomeFirstResponder.
- (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];
});
});
}