UITableView insertRowAtIndexPaths then scrollToRowAtIndexPath draws cell twice
I'm inserting a new cell into my table that I know will not be visible (I know it's off the bottom of the screen), so I then call scrollToRowAtIndexPath, e.g.
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:myIndexPath] withRowAnimation:UITableViewRowAnimationBottom];
[tableView scrollToRowAtIndexPath:myIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
However, when I do this I can actually see the cell getting drawn/animated twice,开发者_运维问答 and removing the UITableViewRowAnimationBottom from the insert would mean that it would not be animated when the insertion should be visible (e.g. at the 2nd row).
Any ideas how I can fix this animation issue?
Thanks,
PaulYou could check whether the row is visible-- if visible, the skip the scroll, else use UITableViewRowAnimationNone. If you call UITableView's -cellForRowAtIndexPath: , it should return nil if the row is not visible.
精彩评论