方法1:

self.webView  = [[UIWebView alloc]initWithFrame:self.view.bounds];
NSString *path = [[NSBundle mainBundle]pathForResource:@"index" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:html baseURL:nil];
[self.view addSubview:self.webView];

 

方法2:

NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:html baseURL:baseURL];

 

相关文章:

  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-01-18
  • 2021-12-17
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案