Uitableview 如何通过在搜索栏上键入时可以搜索其名称或字母的搜索来获取my tableviewcell中的项目?
类RevenueListViewController:UIViewController{Uitableview 如何通过在搜索栏上键入时可以搜索其名称或字母的搜索来获取my tableviewcell中的项目?,uitableview,search,swift3,uiviewcontroller,Uitableview,Search,Swift3,Uiviewcontroller,类RevenueListViewController:UIViewController{ var filterRevenueList = [RevenueThisCycleListModelProtocol]() var output: RevenueThisCycleListViewOutput? var listRevenue: [RevenueThisCycleListModelProtocol] = [] @IBOutlet weak var searchRevenueList: Se
var filterRevenueList = [RevenueThisCycleListModelProtocol]()
var output: RevenueThisCycleListViewOutput?
var listRevenue: [RevenueThisCycleListModelProtocol] = []
@IBOutlet weak var searchRevenueList: SearchTextFieldWithDarkIcon!
@IBOutlet weak var tableViewRevenueList: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
searchRevenueList.textField.placeholder = "Search"
searchRevenueList.textField.addTarget(self, action: #selector(didSearchTextFieldChanged(_:)), for: .editingChanged)
tableViewRevenueList.dataSource = self
tableViewRevenueList.delegate = self
tableViewRevenueList.register(UINib(nibName: "TopSLTableViewCell", bundle: Bundle.main), forCellReuseIdentifier: "TopSLTableViewCell")
tableViewRevenueList.register(UINib(nibName: "TopSLSectionTableViewCell", bundle: Bundle.main), forCellReuseIdentifier: "TopSLSectionTableViewCell")
output?.viewWillAppear(view: self)
}
@objc fileprivate func didSearchTextFieldChanged(_ sender: UITextField) {
}
}
扩展RevenueListViewController:UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return listRevenue.count
}
}
我已经有一个搜索栏,它有一个操作,它必须有一个方法在里面,以获得我的tableviewcell中的项目。谢谢你的帮助
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableViewRevenueList.dequeueReusableCell(withIdentifier: "TopSLTableViewCell") as! TopSLTableViewCell
let revenue = listRevenue[indexPath.row]
cell.configure(revenue: revenue, cellForItemAt: indexPath.row)
return cell
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableViewRevenueList.dequeueReusableCell(withIdentifier: "TopSLSectionTableViewCell")
return cell
}