【发布时间】:2021-01-15 08:36:11
【问题描述】:
我正在尝试以编程方式将WKWebView 添加到我的webViewContainer(类型=UIVIew)作为subView。当我在 iPhone 11 iOS 13.3 但在 iPhone 6 iOS 11.0.1 中测试时,下面的代码完美运行。问题是webViewContainer 有leading(值= 10)和trailing(值= 10)空格和self.view。当我在 iPhone 6 中运行它时,只有leading 受到尊重,trailing 也不受尊重。当我调试时,webViewContainer 和我添加的webView 得到了与webViewContainer 相同的帧。
可能是什么问题?
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.frame.size = self.webViewContainer.frame.size
webView.uiDelegate = self
webView.navigationDelegate = self
self.webViewContainer.addSubview(webView)
【问题讨论】:
-
如果您不介意,可以分享您的约束代码吗?
-
@sekoyaz 我从 xib 文件中进行约束
-
在添加为子视图 put 和 webView.translatesAutoresizingMaskIntoConstraints = false 之前,您可以检查一下吗?
-
@sekoyaz 好的,我现在检查一下
-
@sekoyaz 没问题。谢谢你:)
标签: ios swift xcode uiview wkwebview