I have a tabbar iPhone application in which tabbar is the root controller and each of the tabs is launching a separate webview window. Each time user taps one of the tabs I intercept the tap in AppDelegate and perform actions, one of which is displaying loading screen (an image in the tabbar view, with display toggled TRUE/FALSE).
My problem is, the loading screen is only displayed when all operations in AppDelegate are finished, which pretty much defeats the purpose of it. My guess is that I did some fundamental error designing this solution, but being a very inexperienced in iPhone programing I don’t know how to fix it.
I’m accessing the function showLoading through iboutlets defined in AppDelegate:
[hv showLoading];
And this is what it does:
- (void) showLoading
{
loadingView.hidden = FALSE;
wheelHome.hidden = FALSE;
[wheelHome startAnimating];
NSLog(@"showLoad 1");
}
I’m seeing the “showLoad 1” immediately after bar is tapped, but loading image is only displayed when didSelectViewController exits.
My question – how can I make loading screen appear from AppDelegate OR is there a better way to display loading screen?
The problem is, that the UI is only updated when the event handling code returns to the run loop. You have two options:
[myDownloader persormSelector:@selector(download) withObject:nil afterDelay:0];. The benefit of usingperformSelector:withObject:afterDelay:is that your code returns to the run loop, gets time to update the UI, and then immediately starts the task.