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

标签 iphone objective-c ios ipad

我正在使用 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 - 为什么 UIButton.addTarget 需要在表示操作的字符串后加上 ":"?

ios - 在注释标注 Swift 中隐藏按钮

ios - 如何折叠 iPhone 上的键盘?

iphone - 检测 UIWebView 内的点击

iphone - 在 UIScrollView 上平滑移动元素

iphone - In House Distribution : re-installing an app over an existing one, 使应用程序出错

javascript - Phonegap - 在插件委托(delegate)中从 Objective-c 向 Javascript 发送消息

iphone - 在 iPad 上为绘图程序实现涂抹工具的好方法是什么?

iphone - 如何在 iOS 中将 UIImage 保存为渐进式 JPEG 格式?

objective-c - 是否可以合并非 ARC 和 ARC 项目代码?