CoreAnimation未提交CATransaction警告

时间:2012-08-09 11:57:44

标签: objective-c macos cocoa core-animation osx-mountain-lion

在Mac OS 10.8上,我在我的应用程序中收到以下警告:

CoreAnimation: warning, deleted thread with uncommitted CATransaction;

它建议在环境中打开CA_DEBUG_TRANSACTIONS = 1来记录回溯,这是我做的。

这是我的回溯的顶部:

0   QuartzCore          0x00007fff88a84b95 _ZN2CA11Transaction4pushEv + 219
1   QuartzCore          0x00007fff88a8476d _ZN2CA11Transaction15ensure_implicitEv + 273
2   QuartzCore          0x00007fff88a8bb6a _ZN2CA5Layer12begin_changeEPNS_11TransactionEjRP11objc_object + 44
3   QuartzCore          0x00007fff88a8cb4e _ZN2CA5Layer10set_boundsERKNS_4RectEb + 452
4   QuartzCore          0x00007fff88a8c908 -[CALayer setBounds:] + 189

有谁知道这个警告是什么,以及如何避免它?

1 个答案:

答案 0 :(得分:7)

我发现将有问题的代码包装成显式CATransaction并禁用操作会使警告消失。

[CATransaction begin];
[CATransaction setDisableActions:YES];
layer.bounds = CGRectMake(0, 0, 1000, 1000);
[CATransaction commit];