我正在使用 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/