我试图将一个html文件加载到我的UIWebView中,但它不起作用.现在是阶段:我的项目中有一个名为html_files的文件夹.然后,我在界面构建器中创建了一个WebView,并在viewController中为它分配了一个插座.这是我用来附加html文件的代码:
-(void)viewDidLoad
{
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"html" inDirectory:@"html_files"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
[super viewDidLoad];
}
这不起作用,并且UIWebView为空.如果能帮上忙我会很感激的.