关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
来源:互联网 发布:ubuntu音乐播放器 编辑:程序博客网 时间:2024/05/21 15:58
原文:http://blog.csdn.net/yangxuanlun/article/details/8938148
最近在使用[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]时,找不到其对应的文件,文件当时是通过 右键->add files to 的方式添加到工程里面的,但是使用[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]时,无论如何都找不到文件,经过了重启工程 、clear工程以及重启电脑等方式都无法解决问题。经过思考和测试,感觉这可能是xcode的一个bug.
解决办法及原理是这样的,[NSBundle mainBundle]其获取的路径是你程序的安装路径下的资源文件位置。 在xcode中采用add file to 方式添加文件时,一般情况下xcode会自动将文件添加到你的资源文件,而且,这些文件在你工程的 build Phases中的 copy Bundle Resources中可以查看到。但是有时候,由于xcode的问题,采用add files to 不能自动添加到你的资源文件中,这时,可以采用copy Bundle Resources下面的“+”号,手动将文件添加到你的资源文件中,这样就可以解决问题了 1 0
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- [[NSBundle mainBundle]pathForResource:@"name" ofType:@"type"] 获取不到本地文件
- [[NSBundle mainBundle]pathForResource:@"XXX" ofType:@"db"]为nil的解决办法
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- NSBundle mainBundle] pathForResource 返回nil的解决办法
- iOS开发中 [[NSBundle mainBundle] pathForResource: ofType:]路径为空的问题
- iOS问题笔记-[[NSBundle mainBundle] pathForResource: ofType:]方法获取不到资源路径
- [[NSBundle mainBundle]pathForResource..取值为空
- [[NSBundle mainBundle]pathForResource..取值为空
- NSBundle MainBundle的路径
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发 [NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS 8 设置导航栏的背景颜色和背景图片
- Handler与线程的关系
- Android工具HierarchyViewer 代码导读
- 利用IPC$空连接进行入侵及防范的方法
- EHCache详细解读
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 深入理解 Laravel Eloquent(二)——中间操作流(Builder)
- 关于net.sf.json.jar 报错问题
- Connection closed by foreign host
- 直播m3u8 参数#EXT-X-DISCONTINUITY
- C#调用Python脚本的简单示例
- qt-4.8.4安装和环境变量配置
- 深入理解 Laravel Eloquent(三)——模型间关系(关联)
- Oralce客户端语言配置