1

I have the following code in my viewcontroller:

var webView: WKWebView!

@IBOutlet weak var containerView: WKWebView!

override func loadView() {
    super.loadView()

    webView = WKWebView()
    containerView = self.webView!
}

override func viewDidLoad() {
    super.viewDidLoad()

    let requestURL = NSURL(string:url)
    let request = NSURLRequest(URL: requestURL!)

    containerView.navigationDelegate = self

    containerView.loadRequest(request)
    containerView.allowsBackForwardNavigationGestures = true

}

Basically I programmatically create a WKWebView and assign it to the storyboard UIView. This results in a blank page being shown. When I create the WKWebView without using the outlet it does work, but this is something I don't want. Any reason why this isn't working?

Hapeki
  • 2,153
  • 1
  • 20
  • 36
  • 2
    http://stackoverflow.com/questions/25665141/migrate-to-wkwebview/37560839#37560839 – Kirit Modi Jun 02 '16 at 13:16
  • This works perfectly. I searched before posting, however I never saw interface builder related answers. This however works after refactoring it a bit. I'll post the code underneath for others. Could you post your answer as a comment so I can upvote / mark it? – Hapeki Jun 02 '16 at 13:32
  • @Hapeki can you please post your solution? – GarySabo Jan 29 '17 at 15:12

0 Answers0