How to remove cell from static UITableView created in Storyboard

前端 未结 7 2372
野性不改
野性不改 2021-02-14 08:11

This should be easy, but I\'m having trouble.

I have a static UITableView with a cell that I would like to remove programmatically if it\'s not needed.

I have a

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-14 08:33

    It for only constant cell

    -(void)tableViewSearchPeopleCellHide:(BOOL)hide{
    
        searchCellShouldBeHidden=hide;
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
        [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
        cell.hidden=hide;
        self.searchPeople.hidden=hide;//UILabel
        [self.tableView reloadData];
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       // UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (searchCellShouldBeHidden) //BOOL saying cell should be hidden
            return 0.0;
        else
            return [super tableView:tableView heightForRowAtIndexPath:indexPath];
    }
    

提交回复
热议问题