UISearchController 自动获得焦点

UISearchController 在页面加载完成后自动获得焦点, 只需要下面一句代码, 注意使用异步,不使用异步没有效果。

- (void)viewDidAppear:(BOOL)animated {

    dispatch_async(dispatch_get_main_queue(), ^{

        [self.searchController.searchBar becomeFirstResponder];

    });

}

你可能感兴趣的:(UISearchController 自动获得焦点)