iOS TableViewCell单击具有目标C的一个单元格时隐藏/取消隐藏多个单元格

时间:2017-08-24 16:53:50

标签: ios uitableview height show-hide

我有一个包含8个单元格的tableView。当你单击单元格2时,我想要隐藏/取消隐藏单元格3-5。但是我不知道如何将这些单元格编号发送到高处,或者我是否在弄乱。我还需要知道如何在高度变化后刷新菜单。提前谢谢。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if([indexPath row] == 1){
        '';//

    }else if([indexPath row] == 2){

         if( viewCells ==0){
             viewCells =1;
             //  What needs to be here to change the 3-5 index height
         }else{
             viewCells =0;
             //  What needs to be here to change the 3-5 index height
         }
    }else if([indexPath row] == 3){

        //
    }else if([indexPath row] == 4){

        //
    }else if([indexPath row] == 5){

        //
    }else if([indexPath row] == 6){

        //
    }else if([indexPath row] == 7){

        //
    }else if([indexPath row] == 8){
        //
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if(viewCells==0){

        return 44;
    }else{

        return 0;
    }
    return 44;
}

1 个答案:

答案 0 :(得分:0)

在朋友的帮助下,我得到了它的工作。这是代码。

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES];

    KYDrawerController menu =(KYDrawerController )self.parentViewController; UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@" MainStoryboard"捆绑:无]; if([indexPath row] == 1){     // } else if([indexPath row] == 2){     _advanced =!_advanced;     [[self tableView] reloadData];     返回; } else if(_advanced){     if([indexPath row] == 3){         //     else if([indexPath row] == 4){         //     } else if([indexPath row] == 5){         //     } else if([indexPath row] == 6){         //     } else if([indexPath row] == 7){         //     } else if([indexPath row] == 8){         //     } }其他{     if([indexPath row] == 3){         //     else if([indexPath row] == 4){         //     } } [menu setDrawerState:KYDrawerControllerDrawerStateClosed animated:YES]; [menu reloadInputViews]; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(!_ advanced&& indexPath.row> 2){     indexPath = [NSIndexPath indexPathForRow:indexPath.row + 4 inSection:indexPath.section]; } return [super tableView:tableView cellForRowAtIndexPath:indexPath]; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 如果(!_高级)     return [super tableView:tableView numberOfRowsInSection:section] - 4; return [super tableView:tableView numberOfRowsInSection:section]; }