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

标签 ios cocoa-touch uitableview uisearchbar

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

如果没有匹配的结果,我想删除 No Result TableView。 enter image description here

最佳答案

该 tableView 是自动出现的,因为它是搜索的一部分,但是您可以通过这样做进行修改:

  1. 创建一个名为 noResultsToDisplay(或其他名称)的 bool 标志。
  2. 如果没有要显示的结果,则设置 noResultsToDisplay = YES,否则设置为 NO
  3. numberOfRowsInSection 中,if (noResultsToDisplay) return 3;
  4. cellForRowAtIndexPath 中,if (noResultsToDisplay && indexPath.row == 2) cell.textLabel.text = @"No Results";

关于ios - 如何在 iOS 中删除 UITableViewCell 的 No Result TableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10178794/

相关文章:

objective-c - 从多个 ImageView 中识别特定 ImageView

iphone - 自定义 UITableViewCells

ios - 带有 Firemonkey 的 iAd?

ios - 应用链接验证器 "domain missing from entitlement"

iphone - 长时间运行的 REST API

ios - 4 个 View Controller 之间的简单自定义导航

ios - UITableView 动画故障

ios - PFQueryTableViewController 使用 includeKey 加载一行

ios - 创建后更改注释图像

objective-c - touchXML:stringValue 未保存为字符串?