0

So I am trying to preload all tab views from the app delegate to save time on loading once the user is switching between tabs.

I have tried running this in the view controller file for the UITabBarController (specifically in the viewDidLoad) however have had no luck. Am I missing something?

 let this = self.view
 if let viewControllers = self.viewControllers {
      for viewController in viewControllers {
           let this = viewController.view
      }
 }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
dwinnbrown
  • 3,789
  • 9
  • 35
  • 60
  • Good idea about loading the views, but I don't believe that trying to get the ViewController's view will make it load. I suggest taking the code that will take a while (e.g. - downloading data) and putting that in your AppDelegate. Simple things such as setting the title of a label etc. won't take that long. – Pranav Wadhwa Jul 15 '16 at 21:17
  • Hmm ok...it's loading a local html file into a webview and there is a noticeable delay due to sound files that are linked within the html. – dwinnbrown Jul 15 '16 at 21:24

1 Answers1

0

Try instantiating your view controller...

First set the storyboard id of your view controller

Then:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController")

Note: it is possible that if you put the code in the app delegate, the view controller could be uninstantiated. If this is the case, try putting the code in your first view controller.

Community
  • 1
  • 1
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61