创建包含所有图像的自定义目录。设计它是自定义的,因为它会帮助我在配置中的各个位置获取图像。使用NSBundle从自定义目录中读取图像文件
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
[filemgr createDirectoryAtPath: @"/Users/home/lifemoveson/test" withIntermediateDirectories:YES attributes: nil error:NULL];
我放置了测试文件夹下的图片,并且是.png类型。 有没有办法像下面那样检索图像。
/**再次更新**/
目前这个文件夹正在APPLICATION_HOME /资源/ 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;
}
你有没有得到任何解决方案?我也面临同样的问题 – priya