从XCode调用本地HTML文件时出现问题 [英] Problem calling a Local HTML File from XCode

查看:177
本文介绍了从XCode调用本地HTML文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的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文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆