I face an issue when I put
WKWebView
to View
. As you can see Web page doesn't show from the begin.When I change the app window size the page shows correctly.
What could be the problem?
import SwiftUI
import WebKit
struct WebView: NSViewRepresentable {
func makeNSView(context: Context) -> WKWebView {
let view = WKWebView()
guard let url = URL(string: "https://github.com/filimo/ReaderTranslator") else { return view }
view.load(URLRequest(url: url))
return view
}
func updateNSView(_ view: WKWebView, context: Context) {
}
}
struct WKWebViewDemo: View {
var body: some View {
WebView()
}
}
I left the link with images on https://stackoverflow.com/q/58491837/4067700
If I added Text with multiple lines then WebView is trunced of the top.
var body: some View {
VStack {
Text("line\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\n")
WebView()
}
}