Objective c iOS 6:CoreAnimation:警告,已删除未提交CATTransaction的线程
我收到一个未提交的CATTransaction警告,我无法解决。我的应用程序运行良好,它正在做我期望的每一件事,屏幕以我需要的速度更新标签,一切看起来都很好Objective c iOS 6:CoreAnimation:警告,已删除未提交CATTransaction的线程,objective-c,xcode,ios6,Objective C,Xcode,Ios6,我收到一个未提交的CATTransaction警告,我无法解决。我的应用程序运行良好,它正在做我期望的每一件事,屏幕以我需要的速度更新标签,一切看起来都很好 Dec 10 10:40:10 my-iPhone myAppName[5967] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in enviro
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.
它是从一个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”之前完成对MyTable的更新,唯一的效果是将时间(+56)更改为更大的数字。
我还尝试使用:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
// edit UILabel here
[UIView commitAnimations];
我在另一篇文章中尝试了这一点,但由于我没有使用核心动画,编译器反对将“CATransaction”作为未声明的标识符,我并不感到惊讶
[CATransaction begin];
[CATransaction setDisableActions:YES];
//
[CATransaction commit];
关于如何确定标签更新是否完成有何建议?正如我所说,该应用程序正在工作,我只需要清除此警告 这个问题在开发者论坛上得到了回答。 原来我是在后台线程上做UIKit工作的 我改了台词:
[self performSelectorInBackground:@selector(updateProgress:) withObject:myLabelString];
致:
我尝试将WaitUntilDone设置为YES,这也起到了作用。另一种确保在主线程上绘制任何UI的方法,如Stephen所述,是使用函数
dispatch\u async()
有关dispatch\u async()
和performselectornmainthread:withObjects:waituntldone:
之间差异的相关文章,请参阅
[CATransaction begin];
[CATransaction setDisableActions:YES];
//
[CATransaction commit];
[self performSelectorInBackground:@selector(updateProgress:) withObject:myLabelString];
[self performSelectorOnMainThread:@selector(updateProgress:) withObject:myLabelString waitUntilDone:NO];
// Perform all drawing/UI updates on the main thread.
dispatch_async(dispatch_get_main_queue(), ^{
// Perform any drawing/UI updates here.
});