First, go to your
Project
, click on
General
, scroll down to
Linked Frameworks and Libraries
, and add
WebKit.framework
as Optional. (I also did it for
UIKit.framework
) See screenshot:
Class wkWebViewClass = NSClassFromString(@"WKWebView");
if(wkWebViewClass) {
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
// ...
wkWebView = [[wkWebViewClass alloc] initWithFrame:frame configuration:config];
[self.view addSubview:wkWebView];
}
else {
uiWebView = [[UIWebView alloc] initWithFrame:frame];
[self.view addSubview:uiWebView];
}