ios - Custom UITableViewCell height yields improper animation -


i working uitableview holds standard size cells @ 44pts. however, there couple larger, 160pts.

in instance, there 2 rows @ 44pts height, larger 160pts row being inserted below, @ index 2 in section.

removal call:

- (void)removerowinsection:(tableviewsection *)section atindex:(nsuinteger)index {     nsuinteger sectionindex = [self.sections indexofobject:section];      nsindexpath *removalpath = [nsindexpath indexpathforrow:index insection:sectionindex];      [self.tableview beginupdates];     [self.tableview deleterowsatindexpaths:@[removalpath] withrowanimation:uitableviewrowanimationautomatic];     [self.tableview endupdates]; } 

delegate call:

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     tableviewsection *section = [self sectionatindex:indexpath.section];      return [section heightforrowatindex:indexpath.row]; } 

section call:

- (nsinteger)heightforrowatindex:(nsinteger)index {     standardcell *cell = (standardcell *)[self.list objectatindex:index];      return cell.height; } 

cell call:

- (cgfloat)height {     return 160; } 

what has me confused when remove larger rows table, start animate, moving underneath row above. when point, 1/4 of way through animation, disappear instead of finishing animation.

it seems table animates row notion it's 44pts, once it's reached point 44pts underneath row above, gets removed table. detail have overlooked give table correct notion automatically animate row removal?

thanks help.

update: tried commenting out height function above (which overrides default returns 44). results in proper animation no skips. fwiw

one way solve animate row height down 44 before deleting:

//mark index paths being deleted , trigger `contentsize` update self.indexpathsbeingdeleted = [nsmutablearray arraywitharray:@[indexpath]]; [tableview beginupdates]; [tableview endupdates];  //delete row [self.tableview deleterowsatindexpaths:@[removalpath] withrowanimation:uitableviewrowanimationautomatic]; [tableview endupdates]; 

and in heightforrowatindexpath:

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     if ([self.indexpathsbeingdeleted containsobject:indexpath]) {         //return normal height if cell being deleted         [self.indexpathsbeingdeleted removeobject:indexpath];         return 44;     }     if (<test tall row>) {         return 160;     }     return 44; } 

there's little bit of bookkeeping going on keep track of index paths being deleted. there cleaner ways this. first thing came mind. here's working sample project.


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 -