存储对相机胶卷中保存的图像的引用
我一直在开发一个简单的应用程序,它允许用户拍照并将其存储在相机胶卷中以供以后使用。为此,我使用 UIImagePickerController 和 UIImageWriteToSavedPhotosAlbum 方法,该方法运行良好。
我的问题是:有什么方法可以将图像的路径存储在相机胶卷中,以便我以后可以使用它再次调用图像?或者,我是否必须将图像保存在应用程序中才能稍后再次使用?
如果有一种简单的方法可以做到这一点,那就太好了,因为在视频中,您只需存储特定视频的 NSUrl,然后调用 MPMoviePlayerController 为您完成所有操作。
任何帮助将不胜感激!
I've been working on a simple application which allows the user to take a photo and store it in the camera roll for later use. To do this, I am using a UIImagePickerController, and the method UIImageWriteToSavedPhotosAlbum, which is working perfectly.
My question is: Is there any way to store the path to the image in the Camera Roll so that I can use that to call the image again later? Or, do I have to save the image in the app in order to use it again later?
It would be great if there was a simple way to do this, as there is with a video where you just store the NSUrl for the particular video, and then call MPMoviePlayerController to do everything for you.
Any help would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,做到这一点其实并不难。在 UIImagePickerDelegate 方法中:
NSDictionary“info”实际上包含存储在相机胶卷上的图像或电影的 url。您只需检查:
,这会将电影保存到相机胶卷,并记录 url。对照片进行类似操作,只需将“kUTTypeMovie”替换为“kUTTypeImage”,然后替换
为
如果您需要将 UIImage 存储在相机胶卷上,则 stackoverflow 上有一篇很棒的文章 使用 NSCoding 保存 UIImage,您可以使用它在应用中存储图像。希望对某人有帮助!
It turns out that it is actually not that hard to do this. In the UIImagePickerDelegate method:
the NSDictionary "info" actually contains the url to the image or the movie which is stored on the Camera Roll. You need only check:
and this will save the movie to the Camera Roll, as well as record the url. Doing it for a photo is analogous, just replace the "kUTTypeMovie" with "kUTTypeImage", and replace
with
If you need to store the UIImage not on the Camera Roll, there is a great post on stackoverflow Saving UIImage with NSCoding that you can use to store the image in your app. Hope that helps someone!