在tableview上实现搜索栏

时间:2017-12-26 11:11:50

标签: ios uitableview uisearchbar

我已经制作了单一视图应用程序。我正在尝试在表格视图中实现搜索我的程序正在崩溃

   func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     /*crashing  */ let cell = tableView.dequeueReusableCell(withIdentifier: "discoveryNewscell") as! DiscoveryNewsTableViewCell  //////crashing 
        cell.newsSneakerImage.image=sneakers[indexPath.row].image
        cell.newsTitle.text=sneakers[indexPath.row].news

        return cell


    } 

如何在表格视图中实现搜索栏搜索操作?您可以从此链接https://drive.google.com/file/d/1e4SuFbZLq7fOUeuJc59wYfIMvas3cJ-a/view?usp=sharing

下载示例代码

1 个答案:

答案 0 :(得分:1)

你在cellID中犯了错误,它与故事板不同。

我将{id}替换为cellForRow& Storyboard cellNew &运行你的项目&它奏效了。

检查输出或您的应用,

enter image description here

相关问题