我试图隐藏取消在UISearchController搜索栏的按钮,但不幸的是设定的viewDidLoad以下()不工作:隐藏取消按钮上的搜索栏在UISearchController
override func viewDidLoad() {
super.viewDidLoad()
searchResultsTableController = UITableViewController()
searchResultsTableController.tableView.delegate = self
searchController = UISearchController(searchResultsController: searchResultsTableController)
searchController.searchResultsUpdater = self
searchController.searchBar.sizeToFit()
searchResultsView.tableHeaderView = searchController.searchBar
searchController.delegate = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.searchBarStyle = .Minimal
searchController.searchBar.showsCancelButton = false
definesPresentationContext = true
}
我有在此委托方法使用上面的代码也试过:
func didPresentSearchController(searchController: UISearchController) {
searchController.searchBar.showsCancelButton = false
}
这种方法工作,但会隐藏它,这是不理想的前短暂显示的取消按钮。有什么建议么?
您可以详细了解您的实现?你在哪里放了searchController.searchBar.showsCancelButton = false –