I am having a problem when trying to implement a WKWebView
in a window in VisionOS
and that when trying to do it in full screen and exiting full screen, the size of the webview changes, becoming smaller or larger while the window remains the same size as before.
I used webView.configuration.preferences.isElementFullscreenEnabled = true
for enabling fullscreen mode. I made a simple code to test this.
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup() {
ContentView()
}
}
}
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
let url: URL
func makeUIView(context: Context) -> WKWebView {
let wkwebView = WKWebView()
wkwebView.configuration.preferences.isElementFullscreenEnabled = true
let request = URLRequest(url: url)
wkwebView.load(request)
return wkwebView
}
func updateUIView(_ uiView: WKWebView, context: Context) {
}
}
struct ContentView: View {
var body: some View {
WebView(url: URL(string: "https://glitch.com/~fullscreen-test")!)
}
}