iphone - 如何有条件地不返回单元格

标签 iphone ios objective-c

在我的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 方法中,是否可以不使用某些单元格填充我的 TableView ?

现在我的方法看起来像这样:

static NSString *CellIdentifier = @"Cell";
    ResultsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell.title.text = [[resultsForCell objectAtIndex:indexPath.row] objectForKey:@"title"];
return cell;

但我想这样做,如果 objectforkey@"title"等于某个东西,它不会显示在 tableview 上或不返回该单元格。我不知道完成此任务的最佳方法。

最佳答案

如果你想“过滤”你的 TableView ,你需要过滤你的源数据。在这种情况下,您需要从 resultsForCell 中删除这些值。

如果您想隐藏这些单元格上的标签,只需将标签的隐藏设置为 true 即可。

关于iphone - 如何有条件地不返回单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17936377/

相关文章:

iphone - 如何让 NSTimer 保持活力?

ios - 从我的iOS应用中读取Apple ID

ios - IBInspectable UIEdgeInsets 未显示在 IBOutlet 中

ios - 架构 i386 的 undefined symbol : "_OBJC_CLASS_$_CkoCsv"

iphone - 哪个按钮调用了该功能?

objective-c - 程序集 Objective-C 类分配错误

iphone - 退出应用后重置亮度

iphone - 如何对@distinctUnionOfObjects的结果进行排序?

iphone - box2d 和 Starling - body 没有正确碰撞

iphone - iOS 上的 360 使用图像序列