How to show keyboard without touching the UISearchbar?

后端 未结 2 2154
死守一世寂寞
死守一世寂寞 2021-01-04 10:12

Can I show the keyboard for UISearchbar on viewWillAppear method call without touching the UISearchbar ?

相关标签:
2条回答
  • 2021-01-04 10:52

    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];
           });
       });
    }
    
    0 讨论(0)
  • 2021-01-04 10:56
    [mySearchBar becomeFirstResponder];
    
    0 讨论(0)
提交回复
热议问题