ios - WKWebView - 在横向视图中忽略正确的“安全区域插图”
问题描述
我对 iOS 开发相当陌生,我正在使用 WKWebView 来呈现我的网站。我正在尝试添加一些约束,但想忽略屏幕截图中标记的横向视图中正确的“安全区域插图”。
这是屏幕截图。
这是代码。
let webConfiguration = WKWebViewConfiguration()
let customFrame = CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: 0.0, height: self.webViewContainer.frame.size.height))
self.webView = WKWebView (frame: customFrame , configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
self.webViewContainer.addSubview(webView)
addConstraints(to: webView, with: webViewContainer)
func addConstraints(to webView: UIView, with superView: UIView) {
webView.translatesAutoresizingMaskIntoConstraints = false
let leadingConstraint = NSLayoutConstraint(item: webView, attribute: .leading, relatedBy: .equal, toItem: superView, attribute: .leading, multiplier: 1, constant: 0)
let trailingConstraint = NSLayoutConstraint(item: webView, attribute: .trailing, relatedBy: .equal, toItem: superView, attribute: .trailing, multiplier: 1, constant: 0)
let topConstraint = NSLayoutConstraint(item: webView, attribute: .top, relatedBy: .equal, toItem: superView, attribute: .top, multiplier: 1, constant: 0)
let bottomConstraint = NSLayoutConstraint(item: webView, attribute: .bottom, relatedBy: .equal, toItem: superView, attribute: .bottom, multiplier: 1, constant: 0)
superView.addConstraints([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])
}
任何帮助将不胜感激。
解决方案
推荐阅读
- google-workflows - 如何将一些参数从父工作流传递给工作流
- php - 编译 PHP 8.0.1 失败
- r - 在函数调用中使用变量时,MASS 包中的 glm.nb 链接函数不起作用?
- r - 将重复的列名与数据表匹配
- excel - 在多张纸上匹配多列?
- python - 有没有办法将此shell代码移植到python?
- javascript - 如何从键分配为“*”的javascript对象中提取数据?
- java - Java:多线程安全问题:使用线程扩展和锁定
- javascript - 具有 Excel 功能的 HTML 表格到 Excel 电子表格
- javascript - WebRTC 获取 IP 不一致