This should be easy, but I\'m having trouble.
I have a static UITableView with a cell that I would like to remove programmatically if it\'s not needed.
I have a
You can use tableView:willDisplayCell
and tableView:heightForRowAtIndexPath
with the cell identifier to show/hide static tableview
cells, but yo must implement heightForRowAtIndexPath
referring to super
, not to self
. These two methods work fine for me:
(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell.reuseIdentifier.description isEqualToString:@"cellCelda1"]) {
[cell setHidden:YES];
}
}
and
(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if ([cell.reuseIdentifier.description isEqualToString:@"cellCelda1"]) {
return 0;
}
return cell.frame.size.height;
}