[英]How can I prevent UISearchController dismiss when cancel button pressed?
當用戶第一次按下取消按鈕時,我只想隱藏鍵盤。
只是喜歡 AppStore.app
我像這樣使用 UISearchController:
navigationItem.searchController = searchController
============== 更新 ==============
這個取消按鈕由 UISearchController 托管。
如果您以編程方式執行搜索欄,則可以在 ViewController 上添加擴展名,或者僅使用如下所示的函數調用。
extension ViewController: UISearchBarDelegate {
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
if let text = searchBar.text {
self.filterContent(text: text)
searchBar.resignFirstResponder()
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.