uitableview - Accordion table cell - for expand and collapse ios -


i trying expand/collapse of tableview cells in accordion cell pattern, that, when user taps row detailed description of selected row within cell extending row height. have 2 arrays, 'array' , 'detailarray' displaying in 'cell.textlabel.text' , 'cell.detailtextlabel.text' cells resp. have made 'cell.detailtextlabel.hidden = yes' hidden, when user taps row can extended text of cell.

my code,

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];      // configure cell...     cell.textlabel.text=[array objectatindex:indexpath.row];     cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row];     cell.detailtextlabel.hidden = yes;      return cell; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath  *)indexpath {     [tableview deselectrowatindexpath:indexpath animated:yes];     nslog(@"indexpath %d", indexpath.row);     selectedindex = indexpath.row;     issearching = yes;      [self.tableview beginupdates];      static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];     cell.textlabel.text=[array objectatindex:indexpath.row];     cell.detailtextlabel.text=[detailarray objectatindex:indexpath.row];     cell.detailtextlabel.hidden = no;      [self.tableview endupdates]; }  - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     if (issearching && indexpath.row == selectedindex)     {                return 77;           }     return 44;     } 

now have created tableviewcell 4 rows , when tapping each row extended view of selected row. during runtime see 'detailarray' text on cell when extends, disappears when didselectrowatindexpath function stopped, why happening so, 1 can me in regards.

check out subtable, handles expanding/collapsing you.

if you're looking single detail cell display under main one, can implement delegate method so:

- (nsinteger)numberofchildcellsunderparentindex:(nsinteger)parentindex {     if (detailarray[parentindex] contains content)         return 1;     else         return 0; } 

and customize cell's height , looks needs


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -