I have two independent `WKWebViewController`. I load the first `WKWebView` and then another `WKWebView` when the button is pressed.
So I want to load another `WKWebView` in advance. How can I do this?
Each of the two ViewControllers has WKWebView.
First WKWebView
func openSecondScreen(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let openSecondScreen = storyboard.instantiateViewController(withIdentifier: "SecondWebViewController") as! SecondWebViewController
openSecondScreen.modalPresentationStyle = .overCurrentContext
openSecondScreen.modalTransitionStyle = .crossDissolve
openSecondScreen.delegate = self
self.navigationController?.pushViewController(openSecondScreen, animated: true)
}
Second WKWebView
override func loadView() {
super.loadView()
let images = global.getIndicatorImage()
let animatedImage = UIImage.animatedImage(with: images, duration: 1.0)
self.indicatorImage.image = animatedImage
contentController.add(self, name: "SecondWeb")
config.userContentController = contentController
secondWebWebView = WKWebView(frame: secondWebWebView.frame, configuration: config)
secondWebWebView.uiDelegate = self
secondWebWebView.navigationDelegate = self
view.addSubview(secondWebWebView)
view.addSubview(indicator)
if contentController.userScripts.count > 0 {
contentController.removeAllUserScripts()
}
let localFilePath = Bundle.main.url(forResource: webUrl, withExtension: "html")
let myRequest = URLRequest(url: localFilePath)
secondWebWebView.load(myRequest)
}
How can I solve this problem?