我有UITableViewController
静态分组单元格。在特定视图中,我想删除一些单元格。如果我只是隐藏它们,它会留下一个空白空间,所以我想将单元格设置rowHeight
为0
。我在执行此操作时遇到了麻烦,因为我似乎无法获得要隐藏的单元格的 indexPath。我通过 IB 连接引用了它。在阅读之后,似乎最好的方法是通过heightForRowAtIndexPath
方法。这是我的代码:
- (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;
}
在此之前,我正在尝试IndexPathForCell
,但也会崩溃。从我阅读的内容来看heightForRowAtIndexPath
,即使细胞不可见,也应该可以工作。当它崩溃时,调试器中也没有任何显示。