我的应用程序如何保存并打开iPhone照片库中的照片?

问题描述:

如何从我的应用程序中保存并打开iPhone照片库中的照片?代码将会有帮助。我的应用程序如何保存并打开iPhone照片库中的照片?

你能做的最好的保存关闭在自己的应用程序所拍摄的照片可写目录,然后使用它...请注意,如果您多次保存到用户库,它将每次都会创建一个新的映像。

您可能需要提交与苹果Radar以允许对文件的直接访问,或给你一些参考,你可以用它来查看文件(看到例如EXIF)。

+0

我会那样做.__ – cduck 2010-01-04 07:48:51

这使您可以将图像保存到相册:

// Adds a photo to the saved photos album. The optional completionSelector should have the form: 
// - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo; 
UIKIT_EXTERN void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo); 

(示例代码:)

IImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 


/// called function, alerts user when the image has been saved: 

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { 
    [ [ self parentViewController ] dismissModalViewControllerAnimated: YES]; 
} 
+0

如何在下次启动我的应用程序时用户不必从UIImagePickerController中选择图像的情况下重新打开图像? – cduck 2010-01-04 06:41:36

+1

不幸的是,在做了一些挖掘之后,可能无法通过AppStore发布应用程序。您可以将它们保存到相册和您自己的目录(并且您可以在自己的目录中打开这些目录而没有任何问题),但是应用程序无法访问相机的相册。 – justin 2010-01-05 00:23:53