开发者

Is there a way to hide a cell in a UITableView (Grouped)?

开发者 https://www.devze.com 2023-04-04 14:44 出处:网络
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

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消