最近遇到一个问题:如何把H5添加到xcode项目中?而不是通过URL的形式来引用它。经过多方查证最终找到一个方法,现在把它分享出来,希望对大家有所帮助!
1、在xcode中新建一个文件夹,来存放你的H5页面、image等。选择Create groups。
2、添加的 .html、image文件时选择 Create folder references。
3、最后添加如下代码,引用你需要的.html页面。
//创建要打开的html文件的完整路径 NSBundle *bundle = [NSBundle mainBundle]; NSString *resPath = [bundle resourcePath]; NSString *filePath = [resPath stringByAppendingPathComponent:@"jieting.html"]; //初始化一个UIWebView实例 _webView = [[WKWebView alloc] initWithFrame:self.view.frame]; //加载指定的html文件 [_webView loadRequest:[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initFileURLWithPath:filePath]]]; [self.view addSubview:_webView];
本文地址:https://blog.csdn.net/qq_45039822/article/details/107518101
如对本文有疑问, 点击进行留言回复!!
纵横字谜的答案 Crossword Answers, ACM/ICPC World Finals 1994, UVa232
HDU - 5880 Family View (AC自动机修改母串)
iOS14Beta3续航怎么样 iOS14Beta3续航能力介绍
iOS14Beta3稳定性怎么样 iOS14Beta3升级建议介绍
网友评论