这应该很简单,但我有麻烦.
我有一个静态UITableView与一个单元格,我想以编程方式删除,如果不需要.
我有一个IBOutlet
- IBOutlet UITableViewCell * cell15;
- cell15.hidden = true;
这隐藏了它,但留下了一个空白的空间,细胞过去是我不能摆脱的.
也许一个黑客会把它的高度改为0?
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:indexPath
- {
- //what would I put here?
- }
非常感谢!
解决方法
你不能真正处理这个数据源,因为使用静态表,你甚至没有实现数据源方法.高度是走的路.
尝试这个:
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- if (cell == cell15 && cell15ShouldBeHidden) //BOOL saying cell should be hidden
- return 0.0;
- else
- return [super tableView:tableView heightForRowAtIndexPath:indexPath];
- }
更新