简体   繁体   English

在tableview上实现搜索栏

[英]implementing search bar on tableview

I have made the single view application .I am trying to implement the search in table view My program is crashing at 我已经制作了单视图应用程序。我试图在表视图中实现搜索我的程序在崩溃

   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


    } 

How to implement the search bar Search operation in table view ? 如何在表格视图中实现搜索栏的搜索操作? You can download the sample code from this link https://drive.google.com/file/d/1e4SuFbZLq7fOUeuJc59wYfIMvas3cJ-a/view?usp=sharing 您可以从以下链接下载示例代码https://drive.google.com/file/d/1e4SuFbZLq7fOUeuJc59wYfIMvas3cJ-a/view?usp=sharing

You have done mistake in cellID, It is different from storyboard. 您在cellID中做错了,这与情节提要不同。

I replaced the cellID from cellForRow & Storyboard to cellNew & runned your project & it worked. 我将cellID从cellForRowStoryboard替换为cellNew并运行了您的项目,它成功了。

Check output or your app, 检查输出或您的应用,

在此处输入图片说明

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

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