Q:

delay loading of UIWebView in UITabBar app

I have an UITabBar based iPhone app with 4 different UIWebViews under every tab. Right now all the UIWebViews load on startup and it takes a little bit too long.
I would like to load the default tab's UIWebView first, then load the others in the background. What is the best way to do this?
I have seperate ViewControllers set up for each tab and have this in every .m file:
- (void)viewDidLoad {

NSString *urlAddress2 = @"http://google.com ";

//Create a URL object.
NSURL *url2 = [NSURL URLWithString:urlAddress2];

//URL Requst Object
NSURLRequest *requestObj2 = [NSURLRequest requestWithURL:url2];

//Load the request in the UIWebView.
[webView2 loadRequest:requestObj2];

}

Is there a simple way to tell the other 3 tabs to start loading a few seconds after launch instead of at launch? Would that be a good idea?
Thanks a lot!

A:

I've gotten around this issue by implementing a model layer through which all requests pass.  Requests are queued and serviced in priority order, generally one at a time.  I've added specific methods to allow a controller to escalate the priority of requests so that, if necessary, two or more requests will be active at once.  When a request finishes, it alerts it delegate (the WebView's controller) that data is ready to be loaded.
Depending on how you want to set things up, you can put a callback in "webViewDidFinishLoad" (or, perhaps, shouldStartLoadWithRequest or webViewDidStartLoad) that triggers the model layer to dequeue and service the next request.  For safety, you'll also want a timeout in the model layer.
Note: you'll also need to add some custom code into shouldStartLoadWithRequest to differentiate between clicks and the model layer pushing data in.  I.e. you'll want to return NO or YES depending on the navigationType.

