4

在这个论坛上已经有很多关于“wait_fences: failed to receive reply”的问题,但是没有一个建议的解决方案对我有用(尽管它们确实帮助我减轻了它)。

当我的应用程序启动时,我会进行可达性检查,如果我无法访问我正在寻找的主机,我会弹出一个 UIAlertView。最初我什至在设置视图控制器之前就这样做了,但后来我了解到“wait_fences”问题的原因之一是如果您还没有显示视图,则响应程序链没有正确设置 - 所以我将所有内容都移到了 -viewDidAppear 中。基本上,这就是我所拥有的:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // Figure out what the reflections name is, then check to see if it can find it online;
    // If it can't, -informUserSiteIsNotReachable is called, below
    [self retrieveReflectionByName:self.todaysReflectionName];

    [self displayReflectionByName:self.todaysReflectionName];
}

- (void)informUserSiteIsNotReachable 
{
    SEL messageSelector;

    if (NO == [self internetIsReachable]) {
        messageSelector = @selector(internetNotAccessible);
    } else {
        messageSelector = @selector(reflectionsSiteNotAccessible);
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[Strings alertViewTitleWhenSiteIsUnreachable] message:[Strings performSelector:messageSelector]  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:NULL];
    [alert show];
    [alert release];
}

我似乎无法摆脱 wait_fences 问题:有什么建议吗?

4

1 回答 1

0

在这里,我在项目中也遇到了同样的问题,我解决了“wait_fences”的问题。

在这里,您可以对代码进行如下更改:

- (void)informUserSiteIsNotReachable 
{
    SEL messageSelector;

    if (NO == [self internetIsReachable]) {
        messageSelector = @selector(internetNotAccessible);
    } else {
        messageSelector = @selector(reflectionsSiteNotAccessible);
    }

    [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(Show_AlertMessage) userInfo:nil repeats:NO];
}

- (void) Show_AlertMessage
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[Strings alertViewTitleWhenSiteIsUnreachable] message:[Strings performSelector:messageSelector]  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:NULL];
    [alert show];
    [alert release];
}

这对我有用。希望你尽快摆脱这个 wait_fences 问题。如果您仍然有问题,请告诉我。

于 2011-07-02T08:09:38.240 回答