2017-08-24 86 views
-1

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

- (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

选择您的代码并点击控制+ k。它将正确格式化。这与问题无关。 –

回答

0

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

  • (无效)的tableView:(UITableView的*)的tableView didSelectRowAtIndexPath方法:(NSIndexPath *)indexPath { [的tableView deselectRowAtIndexPath:indexPath动画:YES];

    KYDrawerController menu =(KYDrawerController)self.parentViewController; UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@“MainStoryboard”bundle:nil];如果([indexPath row] == 1){ // } else if([indexPath row] == 2){更新=!_ advanced; [[self tableView] reloadData]; return; }否则如果(_advanced){ 如果([indexPath行] == 3){// } 否则如果([indexPath行] == 4){// } 否则如果([indexPath行] = = 5){// } 否则如果([indexPath行] == 6){// } 否则如果([indexPath行] == 7){// } 否则如果([indexPath行] == 8){// } }否则{如果 ([indexPath行] == 3){// } 否则如果([indexPath行] == 4){// } } [menu setDrawerState:KYDrawerControllerDrawerStateClosed animated:YES]; [menu reloadInputViews]; }

  • (的UITableViewCell *)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath { 如果(!_先进& & indexPath.row> 2){ indexPath = [NSIndexPath indexPathForRow:indexPath。 row + 4 inSection:indexPath.section]; } return [super tableView:tableView cellForRowAtIndexPath:indexPath]; }

  • (NSInteger的)的tableView:(UITableView的*)的tableView numberOfRowsInSection:(NSInteger的)部分 { 如果(_先进!) 返回[超级的tableView:的tableView numberOfRowsInSection:§ - 4; return [super tableView:tableView numberOfRowsInSection:section]; }