一度、すべての写真を APP Bundle に入れました。imageNamed 関数を使用して画像を取得しました。後で、アプリの起動時にいくつかの写真をドキュメントにコピーすることにしました。そのため、 imageNamed 関数を使用して画像を取得できなくなりました。imageWithContentsOfFile を使用して画像を取得しました。
NSString* documentsDirectoryPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
UIImage* result =[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.%@", documentsDirectoryPath, fileName, extension]];
ただし、imageWithContentsOfFile は低品質の画像 (非常にあいまい) を返します。私の画像はすべて128 * 128です。次のコードを使用して、画像のサイズを検出しました。
NSData * imgData = UIImagePNGRepresentation(image);
NSLog(@"size : %d",[imgData length]);
imageNamed によって返される画像のサイズは、imageWithContentsOfFile の 3 倍であることがわかりました。私は夢中になった...助けて!どうもありがとう ...