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;
- 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
Better option is to update your data before providing loading the table.
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....
精彩评论