【发布时间】:2021-02-23 14:46:02
【问题描述】:
当我在 iPhone 上的 wkwebview 中打开或启动该网站时,它会自动在请求标头中获取应用程序“userAgent”,但在相同的情况下它不会发生在 iPad 上。
在下面创建 WKWebview:
让 wkWebView = WKWebView()
【问题讨论】:
标签: ios swift iphone xcode ipad
当我在 iPhone 上的 wkwebview 中打开或启动该网站时,它会自动在请求标头中获取应用程序“userAgent”,但在相同的情况下它不会发生在 iPad 上。
在下面创建 WKWebview:
让 wkWebView = WKWebView()
【问题讨论】:
标签: ios swift iphone xcode ipad
您可以创建WKWebViewConfiguration 并将其与WKWebView 创建一起传递。
// Create custom configuration object.
let webConfiguration = WKWebViewConfiguration()
webConfiguration.applicationNameForUserAgent = "Add your user agent here."
// Create WebView object with your configuration object.
let webView = WKWebView(frame: view.frame, configuration: webConfiguration)
这样它将适用于您的所有设备。
【讨论】: