【发布时间】:2011-05-22 02:10:44
【问题描述】:
我已经在我的资源包中添加了一个资源(蓝色文件夹),一切似乎都很好,甚至我使用 NSFileManger 来确定文件是否存在,以及它是否打印出检查中使用的完整路径喜欢这样:
NSString *p = [NSString stringWithFormat:@"%@/words/001",
[[NSBundle mainBundle] resourcePath]];
NSFileManager *fm = [NSFileManager defaultManager];
NSString *a = [p stringByAppendingPathComponent:@"001-1.png"];
UIImage *i;
if ([fm fileExistsAtPath:a]) {
NSLog(@"file found ... %@", a);
i = [UIImage imageWithContentsOfFile:a];
}
else {
NSLog(@"doh!");
}
[iv setImage:i];
我从文件存在检查中得到这个输出
/Users/phh/Library/Application Support/iPhone Simulator/4.2/Applications/3DAB4772-7251-4E39-8EA8-4AFE32DFB61A/MyApp.app/words/001/001-1.png
但 UIImage 总是为零?我只是看不到这里发生了什么......
帮助....?
谢谢
【问题讨论】:
-
你从哪里得到的图像是 nil?
-
你的word和001文件夹是蓝色的吗?
标签: iphone ios uiimage nsfilemanager