NSBundle* bundle = [NSBundle mainBundle]; NSString* resPath = [bunder resourcePath]; NSString* filePath = [resPath stringByAppendPathComponent:@"test.html"]; [WebView loadHTMLString:[NSString stringWithContentsOfFile:filePath] baseURL:[NSURL fileURLWithPath:[bundle bundlePath]]];
NSString *fullPath = [NSBundle pathForResource:@"test" ofType:@"html" inDirectory:[[NSBundle mainBundle] bundlePath]]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
本文介绍如何使用Objective-C在iOS应用中从本地加载HTML文件到WebView。通过NSBundle获取资源路径,并使用WebView展示HTML内容。
10

被折叠的 条评论
为什么被折叠?



