objective c - How to hide a section in a table view controller with static cells? -


i have uitableviewcontroller static cells, 3 sections, , segmented control 2 buttons. achieve following behavior:

  • when button 1 pressed hide section 2
  • when button 2 pressed hied section 3

i cannot find solution this. tip useful. thanks.

simple, make sure set uitableviewdelegate, , can use heightforrowatindexpath: (and similar headers , footers) show/hide cells setting height 0.

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     if (indexpath.section == 2) {         if (self.shouldshowsection2) {             return 44.0f;         }else{             return 0.0f;         }     }else if (indexpath.section == 3) {         if (self.shouldshowsection3) {             return 44.0f;         }else{             return 0.0f;         }     }else{         return 44.0f;     } } 

then define logic within ibaction change these bools around in between tableview's begin/end updates, , table show/hide sections want.

- (ibaction)togglesegment:(uisegmentedcontrol *)sender {     [self.tableview beginupdates];     //  change boolean conditions show/hide     [self.tableview endupdates]; } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -