如何将照片从相机胶卷复制/移动到应用程序自己的文档文件夹? UIImagePickerController
通过以下方式返回UIImage *
:
(UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage]
如何将UIImage *
保存为文件(最好嵌入所有EXIF信息)?
答案 0 :(得分:1)
尝试使用以下代码
NSData *data = UIImagePNGRepresentation(image);
NSArray *UsrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *DocsDir = [UsrDocPath objectAtIndex:0];
NSString *path = [DocsDir stringByAppendingPathComponent:@"contents.png"];
//Remove if necessary
BOOL success = [FileManager fileExistsAtPath:path];
if(success){
[FileManager removeItemAtPath:path error:&error];
}
[data writeToFile:path atomically:YES];