简体   繁体   中英

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

As described 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM