-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListALLVC.swift
More file actions
64 lines (40 loc) · 1.72 KB
/
ListALLVC.swift
File metadata and controls
64 lines (40 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// ListALLVC.swift
// KatesSearchInTableList
//
// Created by KatesAndroid on 2021/1/28 PM 7:30 - 9:30
// UISearchResultsUpdating
// using UISearchController instance
import UIKit
class ListALLVC: UITableViewController {
// see ResultDisplayVC
/*func updateSearchResults(for searchController: UISearchController) {
}*/
let ad = UIApplication.shared.delegate as! AppDelegate
// using UISearchController instance to be functioned as segue to ResultDisplay =>
// storyboard ID called "result"
var searchMe: UISearchController! //nullable
override func viewDidLoad() {
super.viewDidLoad()
// UISearchResultsUpdating
if let rvc = storyboard?.instantiateViewController(identifier: "result") as? ResultDisplayVC {
searchMe = UISearchController(searchResultsController: rvc)
// UISearchResultsUpdating
searchMe.searchResultsUpdater = rvc
// show searchbar
tableView.tableHeaderView = searchMe.searchBar
}
}
//---------tableView-----------
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ad.listForAll.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = ad.listForAll[indexPath.row] // textLabel is nullable
return cell
}
}