iOS 17.5 Beta中WKWebView无法加载问题 | Xcode 15.4 Beta
WKWebView在Xcode 15.4 Beta 1、iOS 17.5模拟器及Xcode Cloud中无法渲染内容
我的代码多年来运行无异常,但更新至Xcode 15.4(Beta 1)后,WKWebView无法渲染内容。此前Xcode 15发布后Xcode Cloud就出现了该问题,因此我升级了Xcode版本,目前已将测试URL临时替换为google.com。
以下是项目中用于加载URL的代码:
import WebKit import SwiftUI struct LoginView: View { var body: some View { NavigationView { VStack { WebView(urlString: "https://google.com") .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) } .navigationTitle("Web View") } } #Preview { LoginView() } struct WebView: UIViewRepresentable { let urlString: String func makeUIView(context: Context) -> WKWebView { let webView = WKWebView() webView.navigationDelegate = context.coordinator return webView } func updateUIView(_ uiView: WKWebView, context: Context) { if let url = URL(string: urlString) { let request = URLRequest(url: url) uiView.load(request) } } }
该代码在iOS 17.4模拟器及真机上可正常加载,但在iOS 17.5模拟器中完全无法加载。此外,Xcode Cloud使用iPhone 15 Pro Max iOS 17.4模拟器进行UITests时,也存在WebView渲染问题,相关截图如下:
- iPhone 15 Pro Max iOS 17.5(模拟器):

- iPhone 15 Pro Max iOS 17.4(模拟器):

- Xcode Cloud UITests:

内容的提问来源于stack exchange,提问作者M. Mansuelli
相关产品推荐
相关产品推荐

