ios,html using interactive correlation

Source: Internet
Author: User

1.UIWebView Loading HTML files

2.UIWebView Method of Delegation

UIWebView Loading HTML files

UIWebView Loading a Web page

UIWebView *webview=[[uiwebview alloc] initwithframe:[[uiscreen mainscreen] [bounds]];

Automatically scale the page

Webview.scalespagetofit=yes;

Load the page content, or load the local file loginalipay.html

Nsurl *url=[nsurl urlwithstring:@ "http://baidu.com"];

Nsurlrequest *request=[nsurlrequest Requestwithurl:url];

[WebView Loadrequest:request];

[Self.view Addsubview:webview];

UIWebView loading Local HTML

UIWebView *webview=[[uiwebview alloc] initwithframe:[[uiscreen mainscreen] [bounds]];

Automatically scale the page

Webview.scalespagetofit=yes;

Load the page content, or load the local file loginalipay.html

NSString *path=[[nsbundle Mainbundle] pathforresource:@ "Loginalipay" oftype:@ "html"];

Nsurl *url=[nsurl Fileurlwithpath:path];

Nsurlrequest *request=[nsurlrequest Requestwithurl:url];

[WebView Loadrequest:request];

[Self.view Addsubview:webview];

How to delegate UIWebView

The 1.web view indicates notification when content is loaded. Should return yes to start loading. The type parameter provided by the navigation refers to the source of the request and can be any one of the following:

uiwebviewnavigationtypelinkclicked user has struck a link

uiwebviewnavigationtypeformsubmitted user submits a form

Uiwebviewnavigationtypebackforward user strikes forward or Back button

Uiwebviewnavigationtypereload the user touches the reload button

uiwebviewnavigationtypeformresubmitted user submits the form repeatedly

Uiwebviewnavigationtypeother other actions occur

-(BOOL) WebView: (uiwebview *) WebView shouldstartloadwithrequest: (nsurlrequest *) Request Navigationtype: (Uiwebviewnavigationtype) Navigationtype;

2. Execute this method when loading is started.

-(void) Webviewdidstartload: (uiwebview *) WebView;

3. Execute the method when the load is complete.

-(void) Webviewdidfinishload: (uiwebview *) WebView;

4. Execute this method when the load error occurs.

-(void) WebView: (uiwebview *) WebView didfailloadwitherror: (nserror *) error;

ios,html using interactive correlation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.