繁体   English   中英

CATransaction完成块永远不会触发

[英]CATransaction completion block never fires

为什么这个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];

tableview动画有效,但永远不会执行完成块。 Apple文档说保证完成块可以执行。

哦,男孩,这是如此模糊,我真的很惊讶我发现了问题。

正在重新加载的单元格包含一个UIActivityIndi​​catorView,它工作得很好。 当单元格重新加载时,它会隐式重绘表格单元格,并且在表格单元格中的该过程中会发生startAnimating调用。 不知何故,startAnimating调用会干扰CATransaction完成块。

当我将startAnimating调用包装在dispatch_async块中时,问题就消失了:

dispatch_async(dispatch_get_main_queue(), ^{
    [self.loadingInd startAnimating];
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM