如何在页面出现时自动启用UISearchController中的搜索栏?
这是我在应用程序中搜索的代码。如何在页面出现时自动启用UISearchController中的搜索栏?
self.searchController = UISearchController(searchResultsController: nil)     self.searchController.searchResultsUpdater = self 
    self.searchController.delegate = self 
    self.searchController.searchBar.delegate = self 
    self.searchController.hidesNavigationBarDuringPresentation = false 
    self.searchController.dimsBackgroundDuringPresentation = true 
    self.searchController.searchBar.tintColor = UIColor.gray 
    self.navigationItem.titleView = searchController.searchBar 
    self.definesPresentationContext = true 
我想让我的搜索栏在页面出现时自动激活吗?
剂量任何人有想法做到这一点?你可以看看我的形象来说明。
回答:
尝试添加到viewWillAppear中self.searchController.searchBar.becomeFirstResponder()
以上是 如何在页面出现时自动启用UISearchController中的搜索栏? 的全部内容, 来源链接: utcz.com/qa/261374.html








