Search code examples
iosuitabbarcontrollerpreload

Preloading view from a UITabBar


I have a class that loads a UITabBarController. Each tab opens a UINavigationController.

I am trying to preload views inside my UINavigationControllers. I tried doing this:

UITabBarController * tabBarController = (UITabBarController *)self.centerController;
NSArray *myViewControllers = tabBarController.viewControllers;
for (UINavigationController *navViewController in myViewControllers)
{
    [navViewController loadView];
}

I tried different things but it never gets loaded. Am I doing something wrong?


Solution

  • Thanks Or Arbel, you actually helped me understand the problem. I had to call view on the first UIViewController inside the UINavigationController. Here is the code that works:

    UITabBarController * tabBarController = (UITabBarController *)self.centerController;
    NSArray *myViewControllers = tabBarController.viewControllers;
    for (UINavigationController *navViewController in myViewControllers)
    {
        [[navViewController.viewControllers objectAtIndex:0] view];
    }