菜鸟教程小白 发表于 2022-12-11 22:42:14

ios - 如何在iOS中删除UITableViewCell的No Result TableView?


                                            <p><p>其实我的 TableView 的背景颜色真的是黑色的。
但是,当我使用 SearchBar 和搜索词时,如果没有匹配的数据,则会出现白色的“NO Result”UITableView。
如果没有匹配词,我不想出现带有“NO Result” TableViewCell 的白色背景。
我怎样才能删除那个 White UITableViewCell?</p>

<p>如果没有匹配的结果,我想删除 No Result TableView。
<img src="/image/n7OR3.png" alt="enter image description here"/> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>tableView 是自动生成的,因为它是搜索的一部分,但是您可以通过以下操作进行修改:</p>

<ol>
<li>创建一个名为 <strong>noResultsToDisplay</strong>(或其他名称)的 bool 标志。</li>
<li>如果没有结果显示则设置<code>noResultsToDisplay = YES</code>,否则设置为<code>NO</code>。</li>
<li>在<strong>numberOfRowsInSection</strong>中,<code>if (noResultsToDisplay) return 3;</code></li>
<li>在 <strong>cellForRowAtIndexPath</strong> 中,<code>if (noResultsToDisplay && indexPath.row == 2) cell.textLabel.text = @"No Results";</code></li>
</ol></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在iOS中删除UITableViewCell的No Result TableView?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/10178794/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/10178794/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在iOS中删除UITableViewCell的No Result TableView?