iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了objective-c – iOS 6:CoreAnimation:警告,已删除的线程与未提交的CATransaction大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我收到一个未提交的CAtransaction警告,我无法解决问题.我的应用程序工作得很好它正在做我期望的每件事,屏幕更新标签我想要的速度,它看起来都很好. Dec 10 10:40:10 my-iPhone myAppName[5967] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CAtransaction
我收到一个未提交的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];

有关如何确定标签更新是否完整的任何建议?正如我所说的应用程序正在运行,我只需要清除此警告.

解决方法

这个问题在开发者论坛上得到了解答.
事实证明我在后台线程上做UIKit工作.

我换了一行:

[self performSELEctorInBACkground:@SELEctor(updateProgress:) withObject:myLabelString];

至:

[self performSELEctorOnMainThread:@SELEctor(updateProgress:) withObject:myLabelString waitUntilDone:NO];

我尝试将WaitUntilDone设置为YES,这也有效.

大佬总结

以上是大佬教程为你收集整理的objective-c – iOS 6:CoreAnimation:警告,已删除的线程与未提交的CATransaction全部内容,希望文章能够帮你解决objective-c – iOS 6:CoreAnimation:警告,已删除的线程与未提交的CATransaction所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。