问题描述
这是我的 WebView 代码:
Here's my WebView Code:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
这是我的错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSURL initFileURLWithPath:isDirectory:]: nil string parameter'
有人可以帮忙吗?它说的是 nil 字符串,但 NSURL 字符串是 index.html
Can anyone help? It's saying nil string but the NSURL string is index.html
我唯一的想法是索引文件可能没有正确存储.它在项目目录中 - 与 XCode 项目文件 xcodeproj 和 info.plist 相同的文件夹
My only thought is that perhaps the index file isn't stored correctly. It's in the project directory - the same folder as the XCode project file xcodeproj and the info.plist
推荐答案
检查文件是否已复制到您的应用程序包中.当 [[NSBundle mainBundle] pathForResource:ofType:] 返回 nil 时,很可能包中没有同名的文件
Check that the file is copied to your application bundle. When [[NSBundle mainBundle] pathForResource:ofType:] returns nil very most likely there is no file with this name in the bundle
在 Xcode3 中,右键单击侧栏中的组和文件"标题并选择目标成员资格".确保 index.html 前面的复选框被选中.
In Xcode3 right click the "Groups & Files" header in the side bar and select "target membership". Make sure the checkbox in front of index.html is checked.
这篇关于从 XCode 调用本地 HTML 文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)