gpt4 book ai didi

swift - webkit webview 中的 Google iframe 问题它工作正常

转载 作者:行者123 更新时间:2023-11-28 11:26:15 27 4
gpt4 key购买 nike

我在 WebKit ios 11.2 中使用了此代码,其中我的谷歌地图框架未显示以适合屏幕显示,我附上了屏幕截图。

let topBarHeight = UIApplication.shared.statusBarFrame.size.height +
(self.navigationController?.navigationBar.frame.height ?? 0.0)
webView.frame = CGRect.init(x: 0, y: topBarHeight + 20, width: self.view.frame.width, height: self.view.frame.height - topBarHeight)
self.view.addSubview(webView)
self.navigationController?.isNavigationBarHidden = true

webView.backgroundColor = UIColor.clear
webView.scrollView.isScrollEnabled = false
webView.scrollView.bounces = false

webView.loadHTMLString("<html><body><iframe width=\"\(self.webView.frame.size.width)\" height=\"\(self.webView.frame.size.height-70)\" frameborder=\"0\" style=\"border:0\" src=\"https://www.google.com/maps/embed/v1/place?key=\(GoogleApikey)&q=\(Company.Instance.shopAddress),\(Company.Instance.shopName)\"allowfullscreen></iframe></body></html>", baseURL: nil)

this is the screenshot of webkit

最佳答案

viewDidLoad() 中没有完全设置约束。您应该将代码移动到其他生命周期方法中,例如 viewDidAppear() 并使用以下 HTML 字符串加载它

webView.loadHTMLString("<html><body><iframe frameborder=\"0\" style=\"border:0;width: 100%;height:100%\" src=\"https://www.google.com/maps/embed/v1/place?key=\(GoogleApikey)&q=\(Company.Instance.shopAddress),\(Company.Instance.shopName)\"allowfullscreen></iframe></body></html>", baseURL: nil)

关于swift - webkit webview 中的 Google iframe 问题它工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57970557/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com