加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – iOS 6:CoreAnimation:警告,已删除的线程与未提

发布时间:2020-12-14 17:38:11 所属栏目:百科 来源:网络整理
导读:我收到一个未提交的CATransaction警告,我无法解决问题.我的应用程序工作得很好它正在做我期望的每件事,屏幕更新标签我想要的速度,它看起来都很好. Dec 10 10:40:10 my-iPhone myAppName[5967] Warning: CoreAnimation: warning,deleted thread with uncommit
我收到一个未提交的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,这也有效.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读