How to Migrate to WKWebView?

后端 未结 9 1414
后悔当初
后悔当初 2020-11-30 22:23

I\'m trying to understand how to make use of the new WKWebView in iOS8, can\'t find much information. I\'ve read:

http://developer.telerik.com/featured/why-ios-8s-wk

9条回答
  •  借酒劲吻你
    2020-11-30 22:47

    Swift is not a requirement, everything works fine with Objective-C. UIWebView will continue to be supported, so there is no rush to migrate if you want to take your time. However, it will not get the javascript and scrolling performance enhancements of WKWebView.

    For backwards compatibility, I have two properties for my view controller: a UIWebView and a WKWebView. I use the WKWebview only if the class exists:

    if ([WKWebView class]) {
        // do new webview stuff
    } else {
        // do old webview stuff
    }
    

    Whereas I used to have a UIWebViewDelegate, I also made it a WKNavigationDelegate and created the necessary methods.

提交回复
热议问题