Reference Answer:
In iOS, it is usually uiwebview to implement, of course, after iOS8 can use Wkwebview to implement. There are several ways to do this:
- By implementing the UIWebView proxy method to intercept and determine if scheme is a good deal, then iOS calls the local related API to implement:
123 |
- (BOOLwebview: ( Uiwebview *) Webview Shouldstartloadwithrequest: ( Span class= "crayon-t" >nsurlrequest *) Span class= "crayon-v" >request Navigationtype: (uiwebviewnavigationtype Navigationtype |
- After iOS7, it can be implemented directly through the Javascriptecore library, by injecting objects into the JS DOM, which corresponds to an instance of a class in our iOS. For more details, please read:
- OC JavaScriptCore and JS interaction
- Wkwebview new features and JS interaction
- Swift JavaScriptCore and JS interaction
- Can be achieved by Webviewjavascriptbridge. Specific how to use, please go to other blog search it!
Advantages and Disadvantages
- iOS joins the H5 response is much slower than the native, the experience is not very good, this is the disadvantage.
- iOS join H5 can be embedded in other functional portals, can be changed at any time, without updating the version can be online, this is the biggest advantage
How to mix HTML5 development apps in the app. What are the pros and cons of using HTML5 in your app?