У меня возникает проблема, когда я ставлю WKWebView
на View
. Как видите, веб-страница не отображается с самого начала.

Когда я изменяю размер окна приложения, страница отображается правильно.

В чем может быть проблема?
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()
}
}
Если я добавлю текст с несколькими строками, WKWebView будет переведен больше.
struct WKWebViewDemo: View {
var body: some View {
VStack {
Text("line\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\nline\n")
WebView()
}
}
}
