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