【问题标题】:wait_fences: failed to receive reply: 10004003 errorwait_fences:未能收到回复:10004003 错误
【发布时间】:2023-03-22 19:35:01
【问题描述】:

我有一些在块(完成块)中运行的简单代码。在完成块中,如果块中的进程返回 FALSE,我想显示一个 UIAlertView。作为最佳实践,您不应该在后台线程中调用任何 UI 方法,因此我使用 dispatch_get_main_queue 来显示 UIAlertView。这可以正常工作,只是当按下 UIAlert 视图中的取消按钮时,我收到 wait_fences: failed to receive reply: 10004003 错误消息。

代码如下。我不知道该怎么做,据我所知,代码看起来是正确的并且应该可以工作,但显然它存在问题。我希望另一双眼睛可以帮助找到问题。

    __block bool theResult;
    [self.mbProgressHUD showAnimated:YES whileExecutingBlock:^{
      theResult = [someClass someMethodThatReturnsTRUEorFALSE];
    } completionBlock:^{
      [self.mbProgressHUD removeFromSuperview];
      if (theResult) {
        dispatch_async(dispatch_get_main_queue(), ^{
          UIAlertView *theAlert....
          [theAlert show];
        });
      };
    }];

似乎一切正常,除非在 UIAlert 中选择了 OK 按钮。我收到 wait_fences: failed to receive reply: 100040003 错误消息。

任何帮助将不胜感激。

【问题讨论】:

    标签: objective-c ios ios5


    【解决方案1】:

    removeFromSuperview 直接影响视图层次结构,这算作触摸 UI。您无法从后台线程触摸 UI。您还需要将[self.mbProgressHUD removeFromSuperview]; 放入主队列。

    【讨论】:

    • 我也试过了。我已经将完成块中的所有内容包装在一个 dispatch_asynch(dispatch_get_mainqueue(), ^{}) 块中。同样的问题。我刚刚又试了一次,结果还是一样。
    • 这整个 sn-p 是否在后台线程上? showAnimated:... 也需要在主线程上。
    猜你喜欢
    • 2011-05-02
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 2010-11-29
    • 1970-01-01
    • 2011-02-05
    • 1970-01-01
    • 2011-05-13
    相关资源
    最近更新 更多