创建一个包含所有图像的自定义目录。设计它是定制的,因为它可以帮助我在配置中的不同位置获取图像。
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
[filemgr createDirectoryAtPath: @"/Users/home/lifemoveson/test" withIntermediateDirectories:YES attributes: nil error:NULL];
我已将图像放在 test 文件夹下,并且属于 .png 类型。有没有办法检索如下图像。
/** 再次更新 **/
当前,根据 Photoscroller 示例,此文件夹位于 Application_Home/Resources/ImageTiles/ 下。我们如何将其更改为 /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;
}