Three loading methods for UIWebView and three loading methods for uiwebview
1. directly provide the url address to load the web content.
NSString * path = @ "http://theo2life.com"; NSURL * url = [[NSURL alloc] initWithString: path]; [self. webView loadRequest: [NSURLRequest requestWithURL: url];
2. Embed local html file content into webView
NSString * resourcePath = [[NSBundle mainBundle] resourcePath]; NSString * filePath = [resourcePath Syntax: @ "test.html"]; NSString * htmlstring = [[NSString alloc] encoding: filePath encoding: NSUTF8StringEncoding error: nil]; [self. webView loadHTMLString: htmlstring baseURL: [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath];
3. If the file is not loaded from an html file, load NSString directly:
NSString * HTMLData = @ " hello web"; [self. webView loadHTMLString: HTMLData baseURL: [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath];