以下是我的代码,用于显示我的webView
:
public func displayWebView() {
// Javascript functions implementation
let config = WKWebViewConfiguration()
config.userContentController.add(self, name: jsFunc.close.rawValue)
config.userContentController.add(self, name: jsFunc.setTitle.rawValue)
config.userContentController.add(self, name: jsFunc.setBackState.rawValue)
config.userContentController.add(self, name: jsFunc.openAlert.rawValue)
config.userContentController.add(self, name: jsFunc.openDialog.rawValue)
let webFrame = CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: wkContainerView.frame.width, height: wkContainerView.frame.height))
wkWebView = WKWebView(frame: webFrame , configuration: config)
wkWebView.translatesAutoresizingMaskIntoConstraints = false
wkContainerView.addSubview(wkWebView)
wkWebView.topAnchor.constraint(equalTo: wkContainerView.topAnchor).isActive = true
wkWebView.rightAnchor.constraint(equalTo: wkContainerView.rightAnchor).isActive = true
wkWebView.leftAnchor.constraint(equalTo: wkContainerView.leftAnchor).isActive = true
wkWebView.bottomAnchor.constraint(equalTo: wkContainerView.bottomAnchor).isActive = true
wkWebView.heightAnchor.constraint(equalTo: wkContainerView.heightAnchor).isActive = true
wkWebView.uiDelegate = self
wkWebView.navigationDelegate = self
wkWebView.scrollView.bounces = false
}
但是webView
没有出现,这就是控制台打印出来的那些:
(lldb)po webFrame▿(0.0,4.94065645841247e-324, 2.14349191133402e-314,3.62301730942989e-314)▿产地:(0.0,4.94065645841247e-324) - x:0.0 - y:4.94065645841247e-324▿size:(2.14349191133402e-314,3.62301730942989e-314) - 宽度:2.14349191133402e-314 - 身高:3.62301730942989e-314
任何想法都能正确显示我的webView
?