Swift UISearchController
?
1.遵守協(xié)議
UISearchController?
?
2.變量聲明
var sc :UISearchController!
? ?
3.viewDidLoad中實現(xiàn)
? ?sc = UISearchController(searchResultsController: nil)
? ?sc.searchResultsUpdater = self
?
?? sc.dimsBackgroundDuringPresentation = false//是否添加半透明覆蓋層
? ?self.tableView.tableHeaderView = sc.searchBar
?
?
4.實現(xiàn)代理方法
? ?func updateSearchResults(for searchController: UISearchController) {
? ?}
?
?
5. 通過?sc.isActive 屬性對以下方法進行邏輯判斷,重新顯示tableView
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
? ? ? ?
? ? }
?
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
??
? ? }
?
? ?func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
?? ? ? ?
? ? }
?
轉(zhuǎn)載于:https://www.cnblogs.com/chenxiaopao/p/7701834.html
總結(jié)
以上是生活随笔為你收集整理的Swift UISearchController的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Algorithm-Gossip(4)
- 下一篇: MySQL索引的索引长度问题