簡體   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