你有2个选择:
直接插入HTML,如下所示:
UIWebView *wv = [[UIWebView alloc] init];
[wv loadHTMLString:@"
YOUR-TEXT-HERE" baseURL:nil];加载项目中存在的html文件:
UIWebView *wv = [[UIWebView alloc] init];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"] isDirectory:NO];
[wv loadRequest:[NSURLRequest requestWithURL:htmlFile]];
如果您希望您的示例有效,请将您发送的代码替换为:
[super viewDidLoad];
NSURL *htmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]];
[_viewWeb loadRequest:[NSURLRequest requestWithURL:htmlFile]];