I have a tab bar based application with 3 tabs (views). How would I, either in the app delegate or in the first tab that is loaded, would I load the entire contents of the other 2 views in the background?
Right now I have a webView in each of the views in question. Part of my problem is that they are loaded in the viewDidLoad but cause a wait with a blank screen
Thanks
The answer is not that clear to me.. So I you have 3 UIViewController
(or subclasses of them) contained in an UITabBarViewController
, the way to force them to load their view is call the -view
property on each of them in the AppDelegate rich before you add to the UITabbarViewController instance. Something like this:
UIViewController * myViewController = [[UIViewController alloc] initWithNibName:@"mynib" bundle:nil];
[myViewController view];//<--here you are forcing the view to be loaded before it will be called from the tabbatviewcontroller
This is a way to avoid (not at all) the behavior you are experiencing...concepts of loading in background are a lot more complicated.
Try to:
viewController.view.hidden = NO;
for any viewController you want to pre-load and it has beeb allocated and initialized. That is, after alloc and initWithNibName:... has been done.
I typically use something like this:
if (vc.view == nil) // force load of view
{
NSLog(@"%s ***** ERROR: view == nil: %@", __PRETTY_FUNCTION__, vc);
}
NOTE: After calling vc.view, the view should never be nil -- that's a pretty serious allocation bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With