Domanda

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];
    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;
È stato utile?

Soluzione

  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....

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top