簡體   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