From 583ed9d006713dd559d20bb2e3ba933123767cd3 Mon Sep 17 00:00:00 2001 From: ddisfriend Date: Wed, 5 Aug 2026 13:53:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AE=20WKWebView=20?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=20H5=20=E7=9B=B8=E6=9C=BA=E5=86=85?= =?UTF-8?q?=E8=81=94=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - allowsInlineMediaPlayback = true - mediaTypesRequiringUserActionForPlayback = [] 解决车辆管理-行驶证拍摄页面 CameraGuide 组件在 iOS WebView 中预览黑屏/不显示的问题。 --- OrderScheduling/Common/WebView/WebViewController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OrderScheduling/Common/WebView/WebViewController.swift b/OrderScheduling/Common/WebView/WebViewController.swift index df836f0..57dff96 100644 --- a/OrderScheduling/Common/WebView/WebViewController.swift +++ b/OrderScheduling/Common/WebView/WebViewController.swift @@ -24,6 +24,12 @@ class WebViewController : ZDViewController { let config = WKWebViewConfiguration() config.userContentController = WKUserContentController() + // 允许 H5 相机预览在内联播放(iOS WebView 摄像头/WecRTC 必需) + config.allowsInlineMediaPlayback = true + if #available(iOS 10.0, *) { + config.mediaTypesRequiringUserActionForPlayback = [] + } + // 注入环境标识 let script = WKUserScript(source: "window.__IN_APP_WEBVIEW__ = true;", injectionTime: .atDocumentStart, forMainFrameOnly: false) config.userContentController.addUserScript(script)