iOS App 内嵌网页

Mobile Safari- the iOS SDK provides APIs for you to open a specific URL in the built-inMobile Safari browser. In this case, your users temporarily leave the application andswitch to Safari.

UIWebView / WKWebView- Before the release of iOS 9, this is the most convenient

way to embed web content in your app. You can think ofUIWebViewas a stripped-down

version of Safari. It is responsible to load a URL request and display the web content.

WKWebView, introduced in iOS 8, is an improved version ofUIWebView. It has the benefit of

the Nitro JavaScript engine and offers more features. If you just need to display a specific

web page,UIWebVieworWKWebViewis the best option for this scenario.

iOS 9 才有 SFSafariViewController- this is a new controller introduced in iOS 9. While

UIWebViewallows you embed web content in your apps, you have to build a custom web

view to offer a complete web browsing experience. For example,UIWebViewdoesn't come

with the Back/Forward button that lets users navigate back and forth the browsing

history. In order to provide the feature, you have to develop a custom web browser using

UIWebView. In iOS 9, Apple introducedSFSafariViewControllerto save developers from

creating our own web browser. By usingSFSafariViewController, your users can enjoy all

the features of Mobile Safari without leaving your apps.

你可能感兴趣的:(iOS App 内嵌网页)