UITableView的行动画的持续时间和完成回调 [英] UITableView row animation duration and completion callback
本文介绍了UITableView的行动画的持续时间和完成回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法要么指定的UITableView行动画的持续时间,或者得到一个回调的动画完成时?
我想这样做是闪烁滚动指标动画完成后。在此之前做的闪光灯没有做任何事情。到目前为止,我的解决方法是有延迟半秒(这似乎是默认的动画时间),即:
[self.tableView insertRowsAtIndexPaths:newRows
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView performSelector:@selector(flashScrollIndicators)
withObject:无
afterDelay:0.5];
解决方案
对面这个来了。以下是如何做到这一点:
[CATransaction开始]。[的tableView beginUpdates]// ...[CATransaction setCompletionBlock:^ {
// code至完成后执行
}];[的tableView insertRowsAtIndexPaths:indexPaths
withRowAnimation:UITableViewRowAnimationAutomatic];
[的tableView endUpdates][CATransaction提交]
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];
解决方案
Just came across this. Here's how to do it:
[CATransaction begin];
[tableView beginUpdates];
//...
[CATransaction setCompletionBlock: ^{
// Code to be executed upon completion
}];
[tableView insertRowsAtIndexPaths: indexPaths
withRowAnimation: UITableViewRowAnimationAutomatic];
[tableView endUpdates];
[CATransaction commit];
这篇关于UITableView的行动画的持续时间和完成回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文