iOS 自定义.bundle文件中网页资源加载方法
2018-08-10 本文已影响19人
大城子
测试Demo的文件目录结构

加载index.html网页资源所需代码
//获取bundle的路径
NSString *privateBundlePath = [[NSBundle mainBundle]pathForResource:@"TTPWebbrowser" ofType:@"bundle"];
//获取bundle
NSBundle *privateBundle = [NSBundle bundleWithPath:privateBundlePath];
//获取index.html文件路径
NSString *indexPath = [privateBundle pathForResource:@"index" ofType:@"html" inDirectory:@"tianmaomofang"];
//加载index.html网页资源
TTPWKWebViewController *wkWebBrowser = [[TTPWKWebViewController alloc]initWithURL:[NSURL fileURLWithPath:indexPath]];
[self.navigationController pushViewController:wkWebBrowser animated:YES];