iphone - 如何在 UITableView beginUpdates/endUpdates 上

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

相关文章:

ios - 在 iOS 的 UITextView 中检测属性文本的点击

objective-c - 在objective-c中获取NSURL的一部分

ios - 如何使用 Swift 播放本地视频?

objective-c - 取消排队的 performSelector :afterDelay ca

ios - 如何自定义分组表格 View 单元格的背景/边框颜色?

ios - 如何在 iOS 7 下更改 UIPickerView 中文本的颜色?

objective-c - 有没有办法抑制 Xcode 中的警告?

objective-c - 在 switch 语句中声明变量

objective-c - 在什么情况下,我们需要在 ARC 下编写 __autoreleasing

ios - UIButton自定义字体垂直对齐