1 simplest and most basic
Nsurl *url = [Nsurl urlwithstring:@ "http://www.baidu.com"];
Nsurlrequest *request = [Nsurlrequest Requestwithurl:url];
[Self.webview Loadrequest:request];
2 Refer to Import project files remember to put the corresponding JS CSS file
NSString * Htmlpath = [[NSBundle mainbundle] pathforresource:@ "Mall" oftype:@ "html"];
NSString * Htmlcont = [NSString stringwithcontentsoffile:htmlpath encoding:nsutf8stringencoding Error:nil]; Get the current app's root directory
NSString *path = [[NSBundle mainbundle] bundlepath];
Nsurl *baseurl = [Nsurl Fileurlwithpath:path]; HTML that is loaded by means of BaseURL
Files such as js,css,img can be loaded in HTML in relative directories
[Self.webview Loadhtmlstring:htmlcont Baseurl:baseurl];
3 referencing the files in the sandbox (files need to be downloaded to the sandbox, and subsequent collation of the relevant code)
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask,yes);
NSString *docdir = [Paths objectatindex:0];
NSString *filepath = [Docdir stringbyappendingpathcomponent:@ "mall.html"];
Nsurl *baseurl = [Nsurl Urlwithstring:filepath];
NSString *htmlstring=[[nsstring Alloc]initwithcontentsoffile:filepath encoding:nsutf8stringencoding Error:nil];
[Self.webview loadhtmlstring:htmlstring Baseurl:baseurl];
Three ways to refer to iOS development WebView