iOS-当我点击SearchBar时,它会跳到顶部

时间:2018-08-05 15:11:52

标签: ios swift uisearchcontroller

override func viewDidLoad() {
    let searchController = UISearchController(searchResultsController: nil)
    searchController.searchResultsUpdater = self
    searchController.dimsBackgroundDuringPresentation = false
    definesPresentationContext = true
    self.tableView?.tableHeaderView = searchController.searchBar
}

1 个答案:

答案 0 :(得分:0)

将搜索栏添加到tableview标题时,这是默认行为。