ios – 我如何等待UITableView内置动画完成?

ios – 我如何等待UITableView内置动画完成?,第1张

概述参见英文答案 > Callback for UITableView animations                                    2个 >             UITableView row animation duration and completion callback                                    8个 [self. 参见英文答案 > Callback for UITableView animations2个
> UITableView row animation duration and completion callback8个
[self.tableVIEw reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,1)] withRowAnimation:UItableVIEwRowAnimationleft]; [self.tableVIEw reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UItableVIEwRowAnimationRight];

在上面的代码中,如何在第一行的动画完成后执行第二行?

我试过这个……

[self.tableVIEw beginUpdates];[self.tableVIEw reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,1)] withRowAnimation:UItableVIEwRowAnimationleft];{    [self.tableVIEw beginUpdates];    [self.tableVIEw reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UItableVIEwRowAnimationRight];    [self.tableVIEw endUpdates];}[self.tableVIEw endUpdates];

还有这个…

[self.tableVIEw beginUpdates];{    [self.tableVIEw reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,1)] withRowAnimation:UItableVIEwRowAnimationleft];}[self.tableVIEw endUpdates];[self.tableVIEw beginUpdates];{    [self.tableVIEw reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UItableVIEwRowAnimationRight];}

……但无论哪种方式,动画都明显同时发生(当慢动画开启时,动画真的很明显).

解决方法 谢谢IDucool指点我另一个问题.

这工作……

[CATransaction begin];[CATransaction setCompletionBlock:^{    [self.tableVIEw reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UItableVIEwRowAnimationRight];}];[self.tableVIEw reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,1)] withRowAnimation:UItableVIEwRowAnimationleft];[CATransaction commit];

我似乎不需要UItableVIEw的beginUpdates和endUpdates.

总结

以上是内存溢出为你收集整理的ios – 我如何等待UITableView内置动画完成?全部内容,希望文章能够帮你解决ios – 我如何等待UITableView内置动画完成?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1103111.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存