Reputation: 197
I have a series of view controllers and views. This is so I can swipe horizontally through my views.
Each view controller is essentially a different category. So my home screen has 4 buttons that each go to a different view controller. Each view controller has 6 views.
My question - when I go into the view controller, how can I get it to preload all the views in that view controller?
My views are webviews, so I want them to all start loading as soon as I hit the button on my homescreen and go into the view controller. Otherwise I wait for view 1 to load, swipe to view 2, wait for that, swipe to view 3, wait for that etc. So ideally once you wait for view 1 to load, all the others have loaded as well.
This is my current websetup that is in every view:
// Websetup
let productionURL = URL(string:"https://docs.google.com/")
let productionURLRequest = URLRequest(url: productionURL!)
webview1.loadRequest(productionURLRequest)
Could I perhaps call all load requests for the views in the above code?
Upvotes: 0
Views: 587
Reputation: 23634
If you have your request code in the viewDidLoad
function of the view controllers, you can force the view to load by referencing viewController.view
. So you can do something like let _ = myViewController.view
for each one of them when you first initialize them. You can also just break the request loading into a separate function and call that in the exact same way explicitly (and also right after you initialize them).
Upvotes: 1