开发者

How not to show cell in table view if it contains specific string?

I want tableView not to load a cell that contains some string, how to do that?

static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   开发者_Python百科 if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

NSString *itemTitle = item.title;

        if ([item.title isEqualToString: @"Some string"])
{
   // Help needed
}
        else
{
        cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
        cell.textLabel.text =itemTitle;
}
    return cell;


  1. One possible option can be you save indexPath of cell that you don't want to show on screen when table is being loaded and once loading is completed delete them form table using following method.

- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

  1. Better option is to update your data before providing loading the table.

  2. If both of above fails then you can try following method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

Return 0 if you don't want cell to appear on screen. Probably cell with height 0 will not appear.

If above don't work then post here so that i can assist further....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜