UITableView 行动画持续时间和完成回调 [英] UITableView row animation duration and completion callback
问题描述
有没有办法指定 UITableView 行动画的持续时间,或者在动画完成时获得回调?
Is there a way to either specify the duration for UITableView row animations, or to get a callback when the animation completes?
我想做的是在动画完成后闪烁滚动指示器.在此之前进行闪光不会做任何事情.到目前为止,我的解决方法是延迟半秒(这似乎是默认的动画持续时间),即:
What I would like to do is flash the scroll indicators after the animation completes. Doing the flash before then doesn't do anything. So far the workaround I have is to delay half a second (that seems to be the default animation duration), i.e.:
[self.tableView insertRowsAtIndexPaths:newRows
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView performSelector:@selector(flashScrollIndicators)
withObject:nil
afterDelay:0.5];
推荐答案
现在如果你想这样做,有新功能 从 iOS 11 开始:
Nowadays if you want to do this there is new function starting from iOS 11:
- (void)performBatchUpdates:(void (^)(void))updates
completion:(void (^)(BOOL finished))completion;
在更新闭包中放置与 beginUpdates()/endUpdates 部分相同的代码.并且在所有动画结束后执行完成.
In updates closures you place the same code as in beginUpdates()/endUpdates section. And the completion is executed after all animations.
这篇关于UITableView 行动画持续时间和完成回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!