0
我想添加一个搜索栏到一个视图,但我试过了它的一千种方法和搜索栏委托不起作用。SearchBar委托在UISearchController不工作
class SearchTableViewController: UITableViewController, UISearchBarDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.dimsBackgroundDuringPresentation = true
searchController.obscuresBackgroundDuringPresentation = true
self.definesPresentationContext = true
searchController.searchBar.delegate = self
self.tableView.tableHeaderView = searchController.searchBar
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
无论如何,我试过它,它不是委托,UISearchBarDelegate协议失败不起作用,我在UIViewController中试过它,没有任何东西。 – luistejadaa