In my storyboard I have something like a individual navigation bar (three buttons in a row) and below this navbar there should be a WKWebView.
So I create a UIView called webViewSize and implement the WKWebView.
var webView: WKWebView!
@IBOutlet weak var webViewSize: UIView!
override func viewDidLoad() {
super.viewDidLoad()
webView = WKWebView()
webView.navigationDelegate = self
self.webViewSize = self.webView
dispatch_async(dispatch_get_main_queue()) {
if self.url.characters.count > 0 {
if let url = NSURL(string: self.url) {
self.webView.loadRequest(NSURLRequest(URL: url))
self.webView.allowsBackForwardNavigationGestures = true
}
}
}
}
After a few seconds the WK delegate didFinishNavigation is called, but nothing is shown.
When I change self.webViewSize = self.webView
to self.view = self.webView
everything works fine.
I searched a lot to handle this. I worked with subviews, repeat the line self.webViewSize = self.webView
in didFinishNavigation, but nothing work.
What's my mistake?
PS: I know it's Swift 2, but it's an old(er) project. Atm I have to handle this. It will be convert in time.