gpt4 book ai didi

iphone - 如何在 UITableView beginUpdates/endUpdates 上检测到动画已经结束?

转载 作者:IT老高 更新时间:2023-10-28 12:20:07 26 4
gpt4 key购买 nike

我正在使用 beginUpdates/endUpdates 中的 insertRowsAtIndexPaths/deleteRowsAtIndexPaths 插入/删除表格单元格。在调整 rowHeight 时,我也在使用 beginUpdates/endUpdates。默认情况下,所有这些操作都是动画的。

使用 beginUpdates/endUpdates 时如何检测动画已结束?

最佳答案

这个怎么样?

[CATransaction begin];

[CATransaction setCompletionBlock:^{
// animation has finished
}];

[tableView beginUpdates];
// do some work
[tableView endUpdates];

[CATransaction commit];

这是可行的,因为 tableView 动画在内部使用 CALayer 动画。也就是说,他们将动画添加到任何打开的CATransaction。如果没有打开的 CATransaction 存在(正常情况),则隐式开始,在当前运行循环结束时结束。但是,如果您自己开始一个,就像这里所做的那样,那么它将使用那个。

关于iphone - 如何在 UITableView beginUpdates/endUpdates 上检测到动画已经结束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7623771/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com