iphone development NSBundle pathForResource load images from subfolder problem
来源:互联网 发布:主流编程语言排行 编辑:程序博客网 时间:2024/05/16 14:03
+ (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)bundlePath;
- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext;
- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath;
I was fucked by this method today, some guy said it's a bug, eventually I found it's not a bug.
We see Resources/Images folder in project panel in XCode, yes we do see it existing, but if you open your project folder on your hardware, you'll see neither "Resources" folder nor "Images" folder, and the images are exhibited in root
folder of your project, that's why the following is wrong:
NSString *resource = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png" inDirectory: @"images"];
instead if you have this folder “images" in your hardware, you could use above method. otherwise let's
use below one:
NSString *resource = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png" inDirectory: @""];
or
NSString *resource = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"];
The REASON is the "Resources" and "images" folder is just a "SOFT" group structure we saw in XCode, they are not mapping to real folder on hardware, so the compiled app doesn't include this "SOFT" folder structure, then you can't find that file in subfolder.
原因就是我们看到的文件夹结构并不是实际的硬盘上的文件夹结构,所以编译完成的iphone应用程序的bundle里没有这个组织结构。
- iphone development NSBundle pathForResource load images from subfolder problem
- NSBundle pathForResource取不到值
- NSBundle pathForResource取不到值
- NSBundle pathForResource取不到值如何解决?
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- NSBundle mainBundle] pathForResource 返回nil的解决办法
- NSBundle pathForResource取不到值问题
- NSBundle pathForResource取不到值如何解决?
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- NSBundle pathForResource取不到值如何解决?
- [[NSBundle mainBundle]pathForResource..取值为空
- [[NSBundle mainBundle]pathForResource..取值为空
- iphone -- NSBundle
- iphone -- NSBundle
- Tensorflow Image Processing Basic 2: Load Images from folder
- [[NSBundle mainBundle]pathForResource:@"XXX" ofType:@"db"]为nil的解决办法
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- Windbg dump 方法(转)
- CSS左侧导航效果的实现
- 开通博客纪念
- Test whether two objects hold the same data values or both are null
- 2010年终总结
- iphone development NSBundle pathForResource load images from subfolder problem
- JavaScript实现JSP日历
- 编译Boost库
- mysql 动态 SQL 语语
- windbg常用命令
- EJB工作原理
- [Linux][2010-12-31] Linux系统日志 /var/log/messages
- 消息队列MSMQ的使用实例
- java jdbctemple查询