キャッシュまたはドキュメントに保存されている画像に対して、デバイス修飾子 ~ipad、~iphone、@2x を利用する方法はありますか? 私が知る限り、ファイルがメインバンドルに保存されている場合にのみ機能します。
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = ([cachePaths count] > 0) ? [cachePaths objectAtIndex:0] : nil;
NSString *cacheResourcesPath = [cachePath stringByAppendingPathComponent:@"Resources"];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentPath = ([documentPaths count] > 0) ? [documentPaths objectAtIndex:0] : nil;
NSString *documentsResourcesPath = [documentPath stringByAppendingPathComponent:@"Resources"];
// SUCCESS (/caches/resources)
UIImage *image = [UIImage imageWithContentsOfFile:[cacheResourcesPath stringByAppendingPathComponent:@"image~ipad.png"]];
// FAIL (/caches/resources)
UIImage *image = [UIImage imageWithContentsOfFile:[cacheResourcesPath stringByAppendingPathComponent:@"image.png"]];
// SUCCESS (/documents)
UIImage *image = [UIImage imageWithContentsOfFile:[documentsResourcesPath stringByAppendingPathComponent:@"image~ipad.png"]];
// FAIL (/documents)
UIImage *image = [UIImage imageWithContentsOfFile:[documentsResourcesPath stringByAppendingPathComponent:@"image.png"]];
// SUCCESS (main bundle)
UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]];
// SUCCESS (main bundle)
UIImage *image = [UIImage imageNamed:@"image"];