Ios – WKWebView in Interface Builder

iosmacosuiwebviewwkwebviewxcode

It seems that the IB object templates in XCode 6 beta are still creating old-style objects (UIWebView for iOS and WebView for OSX). Hopefully Apple will update them for the modern WebKit, but until then, what is the best way to create WKWebViews in Interface Builder? Should I create a basic view (UIView or NSView) and assign its type to WKWebView? Most of the examples I find online add it to a container view programmatically; is that better for some reason?

Best Answer

You are correct - it doesn't seem to work. If you look in the headers, you'll see:

- (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;

which implies that you can't instantiate one from a nib.

You'll have to do it by hand in viewDidLoad or loadView.