我已经在我的资源包中添加了一个资源(蓝色文件夹),甚至在我使用 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 总是为零?我只是看不到这里发生了什么......
帮助....?
谢谢