为什么这个CATransaction的完成块永远不会发生?
[CATransaction begin];
[CATransaction setCompletionBlock:^{
// table animation has finished
NSLog(@"why does this section never execute?");
}];
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.currentFeedItems.count inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)
tableview动画有效,但永远不会执行完成块.Apple文档说保证完成块可以执行.
Dar*_*ren 12
哦,男孩,这是如此模糊,我真的很惊讶我发现了问题.
正在重新加载的单元格包含一个UIActivityIndicatorView,它工作得很好.当单元格重新加载时,它会隐式重绘表格单元格,并在表格单元格中的该过程中发生startAnimating调用.不知何故,startAnimating调用会干扰CATransaction完成块.
当我将startAnimating调用包装在dispatch_async块中时,问题就消失了:
dispatch_async(dispatch_get_main_queue(), ^{
[self.loadingInd startAnimating];
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1013 次 |
| 最近记录: |