0
let searchController = UISearchController(searchResultsController: nil)
uiView.addSubview(searchController.searchBar)
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
如何將動作添加到搜索欄的取消按鈕。一旦用戶按下取消按鈕,我想重新加載表格的數據。在uisearchController中設置取消按鈕的動作
當我設置searchController.searchBar.delegate = self。不能指定'searchFilterController'類型的值來鍵入'UISearchBarDelegate' – henry
你是否已將UISearchBarDelegate添加到ViewController標題中,比如'class ViewController:UIViewController,UISearchBarDelegate'? –