如何通过搜索在我的tableviewcell中获取项目,当它们在搜索栏上键入时可以搜索其名称或字母?

问题描述

RevenueListViewController类:UIViewController {

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",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

}

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
}

}

我已经有一个具有操作的搜索栏,它内部必须有一个方法才能在tableviewcell中获取项目。谢谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)