UISearchController.searchBar没有响应

时间:2016-12-01 09:38:55

标签: swift3

搜索栏无响应点击/点击?

首先在UIView中创建UITableView

enter image description here

然后在表格标题中添加搜索栏

enter image description here

和取消按钮响应,但不搜索标签。

Conf方法:

func configureSearchController() {

        searchController = UISearchController(searchResultsController: nil)
        searchController.searchResultsUpdater = self
        searchController.dimsBackgroundDuringPresentation = false
        searchController.searchBar.placeholder = "Search here..."
        searchController.searchBar.delegate = self
        searchController.searchBar.sizeToFit()
        searchController.searchBar.showsCancelButton = true
        tableView.tableHeaderView = searchController.searchBar
    }

并从此处致电:

let dimension = CGRect(x: 0, y: 50, width: Int(dialogContainer.layer.frame.width), height: Int(dialogContainer.layer.frame.height - 100))
self.tableView = UITableView(frame: dimension, style: UITableViewStyle.plain)
self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.register(UINib(nibName: "DropdownCell", bundle: nil), forCellReuseIdentifier: "DropdownCell")
self.tableView.backgroundColor = .clear
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none

configureSearchController() // <-

dialogContainer.addSubview(tableView)
self.tableView.reloadData()

0 个答案:

没有答案