我收到了一个未提交的CATransaction警告,我无法解决问题。我的应用程序工作正常,它正在做我期望的每一件事,屏幕更新标签的速度尽可能快,因此我认为它看起来不错。iOS 6:CoreAnimation:警告,删除线程与未提交的CATransaction
Dec 10 10:40:10 my-iPhone myAppName[5967] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.
我设置了CA_DEBUG_TRANSACTIONS = 1并找到下面的列表。
Dec 10 10:43:45 my-iPhone myAppName[5994] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; created by:
0 QuartzCore 0x348fc65d <redacted> + 220
1 QuartzCore 0x348fc541 <redacted> + 224
2 QuartzCore 0x348fc325 <redacted> + 24
3 QuartzCore 0x34900489 <redacted> + 44
4 QuartzCore 0x34905091 <redacted> + 456
5 QuartzCore 0x34904ebf <redacted> + 42
6 QuartzCore 0x34904e91 <redacted> + 44
7 myAppName 0x000d9ec1 -[MainViewController updateProgress:] + 56
8 Foundation 0x3a75067d <redacted> + 972
9 libsystem_c.dylib 0x397d6311 <redacted> + 308
10 libsystem_c.dylib 0x397d61d8 thread_start + 8
导致此警告的代码如下所示:
- (void)updateProgress:(NSString*) myLabelString
{
//this is updating a UILabel on the main view
[myLabel setText:myLabelString];
}
它是从一个叫for循环,我叫performSelectorinBackground:
for (;;) {
// Do stuff here to set up the info for the string
[self performSelectorInBackground:@selector(updateProgress:) withObject:myLabelString];
usleep(100000);
if (stopLoop == YES) {
// do stuff before we exit for loop
break;
}
}
我大多试过几件事情在退出选择器“updateProgress”之前,确保myLable的更新已完成,唯一的影响是将时间(+56)更改为更大的数字。 我也曾尝试使用:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
// edit UILabel here
[UIView commitAnimations];
而且我想这从一个不同的岗位,但我不使用核心的动画,我是不是真的很惊讶,编译反对“CATransaction”作为一个未声明的标识符。
[CATransaction begin];
[CATransaction setDisableActions:YES];
//
[CATransaction commit];
有关如何确定标签更新是否完成的任何建议?正如我所说的应用程序正在工作,我只需要清除此警告。
之间所描述的,使用函数
dispatch_async()
对于相关交上的差随时接受你自己的答案 –
这对我有效。 – Justin