UIWebview中的本地html文件加载

ram*_*ram 2 iphone ipad

我的xcode项目中有一个本地html文件.但我不能用UIWebView加载该本地html文件.

小智 9

实现您的请求的代码是:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 
self.view.frame.size.height,self.view.frame.size.width)];

NSString *indexPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:nil];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:indexPath]]];
[self.view addSubview:webView];
Run Code Online (Sandbox Code Playgroud)