2017-12-18 133 views
0

這是我在應用程序中搜索的代碼。如何在頁面出現時自動啓用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 

我想讓我的搜索欄在頁面出現時自動激活嗎?

劑量任何人有想法做到這一點?你可以看看我的形象來說明。

enter image description here

回答

0

嘗試添加到viewWillAppear中self.searchController.searchBar.becomeFirstResponder()

+0

感謝您的回答 –

相關問題