1、直接给出url地址即可将web content载入。
2、将本地html文件内容嵌入webView
3.如果不从html文件载,直接加载NSString:
NSString *path = @"http://theo2life.com";
NSURL *url = [[NSURL alloc] initWithString:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
2、将本地html文件内容嵌入webView
NSString *resourcePath = [ [NSBundle mainBundle] resourcePath];
NSString *filePath = [resourcePath stringByAppendingPathComponent:@"test.html"];
NSString *htmlstring =[[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]]];
3.如果不从html文件载,直接加载NSString:
NSString *HTMLData = @"<img src=\"test.png\" />hello web";
[self.webView loadHTMLString:HTMLData baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]]];