【发布时间】:2011-07-19 19:55:25
【问题描述】:
这是我的 WebView 代码:
[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
我唯一的想法是索引文件可能没有正确存储。它位于项目目录中 - 与 XCode 项目文件 xcodeproj 和 info.plist 相同的文件夹
【问题讨论】:
-
fileURLWithPath:和isDirectory:之间没有空格 -
这没什么区别。我从教程中复制/粘贴了上面的代码。
标签: objective-c file uiwebview local