【发布时间】:2019-06-16 05:03:32
【问题描述】:
我希望能够使用搜索栏在我的表格视图中进行搜索。
将数据加载到 tableview 工作正常。我不知道如何完成我的 searchBar 函数以便能够按名称搜索。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ContactCell", for: indexPath)
var dic:Dictionary<String,String> = arrayData[indexPath.row] as! Dictionary<String, String>
let nameLb:UILabel = cell.viewWithTag(100) as! UILabel;
nameLb.text = "\(dic["name"]!))"
return cell;
}
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
if(searchText.isEmpty)
{
}
else {
}
tableView.reloadData()
}
【问题讨论】:
标签: ios swift uitableview uisearchbar