Laurent May Laurent May - 19 days ago 4x
iOS Question

Load All TabBar Views

I have a tabbar controller as the root view controller. I would like to pre-load the views of tab [1,2,3] (tab 0 loads as the first tab automatically).

I essentially would like the code in viewdidload to run before the user taps on the tab.



If you take your view initialization code and move it into loadView instead of viewDidLoad you can force each of the UIViewControllers that are part of your UITabBarController to be loaded by simply calling viewController.self. This happens because a UIViewController will create the view object via the loadView function when asked for it.

for(UIViewController * viewController in  tabBarController.viewControllers){

or more simply

[tabBarController.viewControllers makeObjectsPerformSelector:@selector(view)];