As descr开发者_Python百科ibed in the title, I want to hide a cell and not remove it from the table. Is there a way to go about doing this?
You can use next: set variable that handle cell state (hidden or not):
- (float)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == _cellRow)
return _cellHidden ? 0.0f : _cellHeight;
}
And when you want to hide or show cell ask to reload it. This will trigger previous method.
_cellHidden = YES;
[_tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]]
withRowAnimation:UITableViewRowAnimationAutomatic]
精彩评论