ios - How to unhide an animate a UITableView Section? -


in current uitableview have 3 different sections, each section has 1 cell. in between section 1 , section 2 have uisegmentedcontrol 2 different segments.

so give guys idea, think of calculation app, needs know unit using, wether mg/l, or lb's, etc...

i need make section #3 (& it's cell of course) appear if selected segment no.2 example.

if (selectedsegment == 2)     {         //some code animate section & cell in & out if user changes selection in segmented control.     }  

i trying achieve same result can seen when try edit contact in contact book in ios. pressing edit button nice animation goes on display additional sections. when done, animation nicely takes additional sections away, (in case, in case after user has chosen segment #2 , later change mind , go segment #2).

thanks guys!

to started, general idea how work. may need tweak code little bit app.

first edit numberofsections this:

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview {      bool issegment2selected = self.segmentedcontrol.selectedsegmentindex == 1;      if (issegment2selected) {          return 3;      } else {          return 2;     }  } 

then in method gets triggered when segmentedcontrol tapped:

- (void)segmentedcontroltapped:(uisegmentedcontrol *)sender {      bool issegment2selected = self.segmentedcontrol.selectedsegmentindex == 1;      if (issegment2selected) {          [self.tableview insertsections:[nsindexset indexsetwithindex:2] withrowanimation:uitableviewrowanimationfade];      } else {          [self.tableview deletesections:[nsindexset indexsetwithindex:2] withrowanimation:uitableviewrowanimationfade];     } } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -