【发布时间】:2011-09-25 13:24:30
【问题描述】:
创建一个包含所有图像的自定义目录。自定义设计,因为它可以帮助我在需要时在配置中的各个位置获取图像。
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
[filemgr createDirectoryAtPath: @"/Users/home/lifemoveson/test" withIntermediateDirectories:YES attributes: nil error:NULL];
我已将图像放在 test 文件夹下,并且是 .png 类型的。 有没有办法检索如下图像。
/** 再次更新**/
目前此文件夹位于 Application_Home/Resources/ImageTiles/ 下,如 Photoscroller 示例所示。 我们如何将其更改为 /Users/home/lifemoveson/test/ImageTiles/ 文件夹?
- (UIImage *)tileForScale:(CGFloat)scale row:(int)row col:(int)col
{
// we use "imageWithContentsOfFile:" instead of "imageNamed:" here because we don't want UIImage to cache our tiles
NSString *tileName = [NSString stringWithFormat:@"%@_%d_%d_%d", imageName, (int)(scale * 1000), col, row];
// Currently this folder is under <Application_Home>/Resources/ImageTiles/ as per Photoscroller example.
// How can we change it to /Users/home/lifemoveson/test/ImageTiles/ folder ?
NSString *path = [[NSBundle mainBundle] pathForResource:tileName ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
return image;
}
【问题讨论】:
-
你有什么解决办法吗?我也面临同样的问题
标签: iphone objective-c nsfilemanager nsbundle