2017-08-24 2 views
-1

J'ai une tableView qui a 8 cellules. Lorsque vous cliquez sur la cellule 2, je veux cacher/afficher les cellules 3-5.Mais je ne sais pas comment envoyer ces numéros de cellules à la hauteur ou je suis en train de déconner. J'ai aussi besoin de savoir comment actualiser le menu après que la hauteur soit modifiée. Merci d'avance.iOS TableViewCell Cacher/afficher plusieurs cellules en cliquant sur une cellule avec l'objectif 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

Sélectionnez votre code et cliquez sur OK. Il va le formater correctement. Cela n'a rien à voir avec la question. –

Répondre

0

Avec l'aide d'un ami, je l'ai eu au travail. Voici le code.

  • (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) {indexPath [tableView deselectRowAtIndexPath: indexPath animé: OUI];

    KYDrawerController menu = (KYDrawerController) self.parentViewController; UIStoryboard * storyboard = [UIStoryboard storyboardWithName: @ bundle "MainStoryboard": néant]; if ([ligne de chemin d'index] == 1) { // } else if ([ligne de chemin d'index] == 2) { _advanced =! _advanced; [[self tableView] reloadData]; retour; } else if (_advanced) { if ([ligne de indexPath] == 3 de) {// } else if ([indexPath ligne] == 4) {// } else if ([indexPath ligne] = = 5) {// } else if ([rangée de indexPath] de == 6) {// } else if ([rangée de indexPath] de == 7) {// } else if ([indexPath ligne] == 8) {// }} else { if ([indexPath ligne] == 3) {// } else if ([indexPath ligne] == 4) {// }} [menu setDrawerState: KYDrawerControllerDrawerStateClosed animé: YES]; [menu reloadInputViews]; }

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

  • (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) {section si (_ avancé!) retour [super tableView: tableView numberOfRowsInSection: section] - 4; return [super tableView: tableView numberOfRowsInSection: section]; }