and handwriting webview simple introduction of a casing H5 webview

What 1.webview that? What is the role? And browser What is the relationship?

Webview is based on webkit engine that can parse DOM elements, html page to show the controls, and it shows the principle of the browser is the same page, so you can look at it as a browser. (Chrome browser is also based on webkit engine development, Mozilla browser is based on the Gecko engine development)

Android Webview in the low and high version of webkit version uses a different version of the kernel, the 4.4 direct use Chrome.

2.webview mainly used for what? Or what demand will be used to webview?

Understand, the computer display html page, open the page to browse through the browser, while the phone system level, if not webview support, is unable to show html page, so webview role that is used in mobile phone interface system for displaying html

So it is mainly needed in the html files need to be loaded on the mobile phone system

3. a native application invocation html page?

1. Native application loading html page (way to load a page may have a variety, such as load local html files written, or placed in the file server)

2. Load complete show is through webview to render the display, if the system does not webview, it is impossible to render the display html

3.1,2 step is actually a native application calls the html page process has been completed, the page not only show, and sometimes may also need to interact, then here you need to write some methods, and such html interface buttons need something to call the system native (such as : camera, file system, albums and the like). It is responsible for maintaining the original Shengduan html interface to call, then follow the need to return (formerly Shengduan act as a server and a client to act as role html)

4. The benefits of using webview?

Native APP is the layout of the page, as well as business code package then users download and install use, and webview is carried out page display by loading html file, when you need to update the page layout or business logic change, if it is native to APP on you need to modify the contents of the front, the upgrade package, re-release can only be used to date.

And only need to modify the html code or js files by page webview way (if it is acquired from the server side, as long as the new file deployment is complete), refresh the user can use the update, you do not need to download and install the upgrade by way of

The Android built-in browser, the browser comes?

Built-in browser and the browser comes with a concept?

Domestic mobile phone comes with a browser is not chrome, mainly copyright reasons, comes with a browser-based handset makers are several major domestic mainstream own custom browser, and then publish their own versions of the phone system, but several major browsers vendors such as QQ browser, UC browser, are based on the webkit engine

iphone's own browser is Safari, Safari browser is webkit kernel

6.APP webview shows a page and open the mobile browser page?

Based on 6, whether or ios Andrews, comes with all the underlying webkit based browser, and then each system with webview controls are also based on webkit engine, so regardless of APP by calling webview show html page or by opening the browser html page, the effect is the same.


webview H5 casing of a hand into the cash URL

Here is the development steps:

  1. Open the Xcode, here is 8.2.1, the new project, as shown below:Here Insert Picture Description
  2. Create a new blank application, as shown below:Here Insert Picture Description
  3. Fill in the project name, organization, language selection, Objective-C, select the device iPhone, as shown below:

Here Insert Picture Description

  1. Select an item storage directory, a red box is not checked, then click on "Create", as shown below:Here Insert Picture Description
  2. Click on the items below ViewController.m, code into the red box, URL into your web site H5, as shown below:Here Insert Picture Description
 
    // 1.创建webview,并设置大小,"20"为状态栏高度
    CGFloat width = self.view.frame.size.width;
    CGFloat height = self.view.frame.size.height - 20;
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 20, width, height)];
    // 2.创建URL
    NSURL *url = [NSURL URLWithString:@"http://oa.mojocube.com/touch/"];
    // 3.创建Request
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    // 4.加载网页
    [webView loadRequest:request];
    // 5.最后将webView添加到界面
    [self.view addSubview:webView];
 
  1. Click Project Settings >> Info >> Bundle name, modify the APP name, as shown below:
    Here Insert Picture Description
  2. HTTP protocol is used by default blank, and to modify Info.plist, as shown below:Here Insert Picture Description
    Here Insert Picture Description
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
  1. Click Assets.xcassets, APP modified icon, an icon corresponding dimensions directly dragged into the herd, as shown below:Here Insert Picture Description
  2. Click Assets.xcassets, the startup screen, the default startup screen is no need to manually add, as shown below: Here Insert Picture Description
    10. Then set the following two places, as shown below:Here Insert Picture Description
    Here Insert Picture Description
  3. To define the time from the startup screen display, the following code can be provided, as shown below: Here Insert Picture Description
 [NSThread sleepForTimeInterval:3.0];
 [_window makeKeyAndVisible];
  1. Quickly change icons and splash screen, you can modify the following directories to the file, such as the size of the file name, as shown below:Here Insert Picture Description
    Here Insert Picture Description
  2. Compile the test, select the test devices, click the Run button to compile, as shown below:Here Insert Picture Description
  3. These are based on H5 WebView is a native application source code package, if you want to publish to install IPA files, you need to apply for Apple Developer Certificate.

According to the above individual wrote a demo test: https://github.com/BothEyes1993/webappTest

Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin www.cnblogs.com/both-eyes/p/11874563.html