繁体   English   中英

在tableview上实现搜索栏

[英]implementing search bar on tableview

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

   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

您在cellID中做错了,这与情节提要不同。

我将cellID从cellForRowStoryboard替换为cellNew并运行了您的项目,它成功了。

检查输出或您的应用,

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM