我无法加载我的子视图。我将它们定义为弱WKWebKit插座。如果我确实执行view = tickerView或view = graphView,它可以工作,但只加载其中之一。我要同时加载两者。我该怎么办?
override func loadView() {
tickerView = WKWebView()
tickerView.navigationDelegate = self
self.view.addSubview(tickerView)
graphView = WKWebView()
graphView.navigationDelegate = self
self.view.addSubview(graphView)
}
import UIKit
import WebKit
let SCREEN_WIDTH : CGFloat = UIScreen.main.bounds.width
let SCREEN_HEIGHT : CGFloat = UIScreen.main.bounds.height
class ViewController: UIViewController,WKNavigationDelegate{
override func viewDidLoad() {
super.viewDidLoad()
let webView1 = WKWebView()
webView1.frame = CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 200)
webView1.load(URLRequest(url: URL(string: "https://www.google.com/")!))
self.view.addSubview(webView1)
webView1.navigationDelegate = self
let webView2 = WKWebView()
webView2.frame = CGRect(x: 0, y: 250,width: SCREEN_WIDTH,height: 200)
webView2.load(URLRequest(url: URL(string: "https://www.youtube.com/")!))
self.view.addSubview(webView2)
webView2.navigationDelegate = self
}
}