이것은 불가능합니다. UIImagePickerController는 UIImage*
을주고, NSData
으로 변환하고 로컬 샌드 박스에 저장해야합니다. 보안상의 이유로 사용자의 사진 갤러리에있는 이미지에 액세스 할 수있는 SDK 승인 방법이 없습니다.
SDK 3.0을 사용 중이라고 가정하면 피커를 반환하여 응용 프로그램의 문서 디렉토리에있는 디스크에 저장하는 기능이 있습니다 (어딘가에 약간의 실수가있을 수 있음).
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Dismiss the picker
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
// Get the image from the result
UIImage* image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
// Get the data for the image as a PNG
NSData* imageData = UIImagePNGRepresentation(image);
// Give a name to the file
NSString* imageName = @"MyImage.png";
// Now, we have to find the documents directory so we can save it
// Note that you might want to save it elsewhere, like the cache directory,
// or something similar.
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// Now we get the full path to the file
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
// and then we write it out
[imageData writeToFile:fullPathToFile atomically:NO];
}
의미는 - 이미지가 복제 됨 - 이미지는 두 위치, 내 애플리케이션 및 iPhone에 저장됩니다. 그렇습니까? –
예. 불행하게도 Apple은 원본 이미지를 가져올 방법을 제공하지 않습니다. 이 작업은 비공식적으로 사용자의 사진 갤러리 (수동/비공개 장소)를 통해 직접보고 비용이 많이 드는 이미지를 찾기 위해 시도 할 수 있습니다. NSData로 이미지를 디스크에 저장하면 거대한 이미지 (수 메가 픽셀)도 너무 많은 공간을 차지해서는 안됩니다. 그래서 현실에서는 거의 문제가되지 않습니다. – Itay
도와 주시겠습니까, 그 응용 프로그램에 그 UIImage를 저장하는 방법? –