ios - Slide in UITableViewCells while scrolling -
i have uitableview
, animate rows appear again. want switch between animations, cells should uitableviewrowanimationleft
, others uitableviewrowanimationright
. don't know how implement feature uitableviewcontroller
. tried insert following lines of code cellforrowatindexpath
:
[self.tableview beginupdates]; nsarray *updatepath = [nsarray arraywithobject:indexpath]; [self.tableview reloadrowsatindexpaths:updatepath withrowanimation:uitableviewrowanimationleft]; [self.tableview endupdates];
instead of sliding in cell, order of cells changed or of them appeared twice. tried insert these lines after cell creation.
if (cell == nil) { ... } else { [self.tableview beginupdates]; nsarray *updatepath = [nsarray arraywithobject:indexpath]; [self.tableview reloadrowsatindexpaths:updatepath withrowanimation:uitableviewrowanimationleft]; [self.tableview endupdates];
i don't think you're going have success reloading rows once table has started process of displaying cell on screen. reloadrowsatindexpath
typically results in cellforrowatindexpath
being called, i'm surprised you're not getting infinite loop. instead appears, table getting bad state.
my recommendation own animation in case, manipulating cell's transform property in willdisplaycell
. can this:
- (void)tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath { if (<should animate cell>) { cgfloat direction = <animate right> ? 1 : -1; cell.transform = cgaffinetransformmaketranslation(cell.bounds.size.width * direction, 0); [uiview animatewithduration:0.25 animations:^{ cell.transform = cgaffinetransformidentity; }]; } }
you'll need provide logic "should animate cell" - don't want animate cells on initial load.
Comments
Post a Comment