如何将网络视图首选项添加到 swift ui 网络视图
How can I add web view preferences to a swift ui web view
我已经尝试了很多在 playinlinemedia = true 下都无法解决的问题,例如;
struct WebViewY : UIViewRepresentable {
@State var allowsInlineMediaPlayback: Bool = true
let url = URL (string: "https://www.youtube.com?playsinline=1")
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
return WKWebView(frame: .zero)
}
func updateUIView(_ uiView: WKWebView, context: Context) {
let req = URLRequest(url: url!)
uiView.load(req)
}
}
我假设你指的是以下内容
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
return WKWebView(frame: .zero, configuration: webConfiguration)
}
我已经尝试了很多在 playinlinemedia = true 下都无法解决的问题,例如;
struct WebViewY : UIViewRepresentable {
@State var allowsInlineMediaPlayback: Bool = true
let url = URL (string: "https://www.youtube.com?playsinline=1")
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
return WKWebView(frame: .zero)
}
func updateUIView(_ uiView: WKWebView, context: Context) {
let req = URLRequest(url: url!)
uiView.load(req)
}
}
我假设你指的是以下内容
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
return WKWebView(frame: .zero, configuration: webConfiguration)
}