I'm trying to hide the launch screen once the WKWebView finshes loading. I've found a way to detect when the WKWebView has finished loading with the didFinish
delegate, but I'm stuck on hiding the launch screen. At the moment, it sets the webViewFinishedLoading
to true once WKWebView has finished loading, and in ContentView.swift
, It should only show the view if webViewFinishedLoading
is set to false. But right now it only shows the launch screen even after WKWebView finishes loading. Here's my code:
ContentView.swift
:
var webViewFinishedLoading = false
struct ContentView: View {
var body: some View {
SwiftUiWebView(url: URL(string: "myUrl"))
ZStack {
if (!webViewFinishedLoading) {
....
}
}
}
}
WebView.swift
....
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if (webView.isLoading) {
return
}
print("Done Loading")
webViewFinishedLoading = true
}
....
I know that didFinish
gets called because I see "Done Loading" in my debug console.