开发者

UITableView insertRowAtIndexPaths then scrollToRowAtIndexPath draws cell twice

开发者 https://www.devze.com 2022-12-22 03:51 出处:网络
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.

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,

Paul


You 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消