I have UITableViewController
with static grouped cells. In a particular view, I want to remove some of the cells. If I just hide them, it leaves an empty space, so I want to set the cell's rowHeight
to 0
instead. I'm having trouble doing this because I can't seem to get the indexPath of the cell I want to hide. I have a reference to it via IB connection. After reading around, it seems the best way to do this is via the heightForRowAtIndexPath
method. Here is my code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *myIndexPath = [self.tableView indexPathForRowAtPoint:self.billToPostalCell.center];
//crashes here
if ([indexPath isEqual:myIndexPath]) {
return 0;
}
return 44;
}
Before this, I was trying IndexPathForCell
, but also would crash. From what I read, heightForRowAtIndexPath
should work, even when the cells aren't visible. When it crashes, nothing shows up in the debugger either.