How can I load a local HTML file into the UIWebView?

前端 未结 7 980
有刺的猬
有刺的猬 2020-12-09 03:17

How can we load our own html file into the UIWebView?

7条回答
  •  感动是毒
    2020-12-09 03:23

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"privacy-Policy" ofType:@"html" inDirectory:nil];
    NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
    [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
    

提交回复
热议问题