私は1つの問題に直面しています。サポート ファイル グループの下に Album という名前のディレクトリがあります。このディレクトリには、いくつかの画像があります。画像編集アプリで、編集した画像をアルバム ディレクトリに保存したいと考えています。次のコードを使用して、アルバム ディレクトリに画像を保存しようとしました
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSString *albumPath = [bundleRoot stringByAppendingString:@"/Album"];
NSString *savedImagePath = [bundleRoot stringByAppendingPathComponent: @"newImage11.jpeg" ]; UIGraphicsBeginImageContext(drawImage.image.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[drawImage.layer renderInContext:ctx];
UIImage *editedImage = UIGraphicsGetImageFromCurrentImageContext();
NSData *editedImageData = UIImageJPEGRepresentation(editedImage, 1.0); UIGraphicsEndImageContext();
[editedImageData writeToFile:savedImagePath atomically:YES];
ここで drawImage は、画像を保持する UIImageView の IBOutlet です。このコードは、同じサイズのファイル newImage11.jpeg をアルバム ディレクトリに保存しました。しかし、アルバムディレクトリから画像を取得すると、空の画像が表示されます。次のコードを使用して画像を取得しました
NSString *img = [onlyJPGs objectAtIndex:currentIndex+numberToAdd];
UIImage *tempImage = [UIImage imageNamed:img];
imageButton.tag = img;
[imageButton setImage:tempImage forState:UIControlStateNormal];
[imageButton addTarget:nil action:@selector(goToEdit:) forControlEvents:UIControlEventTouchUpInside];
currentIndex+=numberToAdd;
onlyJPGs は、Album ディレクトリに含まれるすべての画像の名前を保持する配列です。ターミナルを使用して ImageEditing.app の Album ディレクトリの内容を一覧表示すると、newImage11.jpeg ファイルが表示されるため、アプリが画像を Album ディレクトリに保存していると確信しています。どんな種類の助けもかなりのものです。