我收到了一個未提交的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