Another "wait_fences: failed to receive reply" Question (UIAlertView)
There are a number of questions regarding the "wait_fences: failed to receive reply" on this forum already, but none of the proposed solutions work for me (although they did help me to mitigate it).
When my app starts up, I do a reachability check, and if I can't reach the host I'm looking for, I pop up a UIAlertView. Initially I was 开发者_JAVA百科doing this before I even set up the view controller, but then I learned one of the causes of the "wait_fences" problem is that the responder chain isn't properly set up if you haven't displayed a view yet - so I moved everything down into -viewDidAppear. Basically, this is what I have:
- (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];
}
I can't seem to get rid of the wait_fences problem: any suggestions?
Here I also faced the same problem in my projects and I solved the issue which is "wait_fences".
Here you can do one change in your code as follows:
- (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];
}
This works for me. Hope you get rid of this wait_fences issue soon. Let me know if you still have the problem.
精彩评论