现在的位置: 首页 > 综合 > 正文

UIWebView 显示本地html及引用资源

2014年09月05日 ⁄ 综合 ⁄ 共 383字 ⁄ 字号 评论关闭

有些软件中可能会用到html页面,比如用在做帮助页面或者其它相关信息时。 这种情况下只需要将html页面文件以及索引用到的资源(图片、声音等) 都加入到bundle中,或者单独创建一个bundle, 在需要的时候调用UIWebView的相关方法即可

 

NSBundle* bundle = [NSBundle mainBundle];

NSString* resPath = [bunder resourcePath];

NSString* filePath = [resPath stringByAppendPathComponent:@"test.html"]; 

[WebView loadHTMLString:[NSString stringWithContentsOfFile:filePath] baseURL:[NSURL fileURLWithPath:[bundle bundlePath]]];

抱歉!评论已关闭.