I am new to swiftui, and I am trying to create a full screen WKWebView. I am testing on an iPad Pro 12.9. When I load the page https://browsersize.com/ I get the follwing:
- iOS app using WKWebView (code below) reports: 1024 x 768
- Mobile Safari reports: 1366 x 917
When I check https://www.ios-resolution.com/ it appears that the device width for an iPad Pro should be 1366 rather than 1024. Why is the WKWebView giving a different width, and is there a way to change this to match mobile safari?
// ContentView.swift
import SwiftUI
import WebKit
struct ContentView: View {
private let urlString: String = "https://browsersize.com/"
var body: some View {
WebView(url: URL(string: urlString)!).ignoresSafeArea()
}
}
struct WebView: UIViewRepresentable {
var url: URL
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ webView: WKWebView, context: Context) {
let request = URLRequest(url: url)
webView.load(request)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
This is related, but it didn't work in my case: How to set iOS WkWebview zoom scale