简体   繁体   English

如何在Swift中打开保存到相册的图像?

[英]How to open an image saved to the Photo Album in Swift?

I am using UIImageWriteToSavedPhotosAlbum to save an image to the user's photo album. 我正在使用UIImageWriteToSavedPhotosAlbum将图像保存到用户的相册。 After that new image is saved, is there a way to open that new file? 保存新图像后,是否可以打开该新文件? (I want to basically take the user to the photo album so that they can share the image if they want) (我想基本上将用户带到相册,以便他们可以共享图像)

You can present a Photos-like interface with UIImagePickerController, but you can't use that to make the user pick that particular photo. 您可以使用UIImagePickerController呈现类似Photos的界面,但是不能使用该界面来让用户选择该特定照片。 The user just sees the whole photos library and can pick any photo, and that's all. 用户仅需查看整个照片库即可选择任何照片,仅此而已。

So, if you just want the user to be able to share this one photo, or alternatively if what you want the user to be able to do with this one photo is share it, then you must fetch it out of the photos library (using the Photos framework) and provide interface for sharing it (using UIActivityViewController). 所以,如果你只是希望用户能够分享这一张照片,或者如果你想要的用户能够与这一个照片做的是股票 ,那么必须用取出来的照片库( (照片框架)并提供共享界面(使用UIActivityViewController)。

Since you are saving the image you could present the image(s) in an image view while the images are being saved and then present the UIActivityViewController to share the image(s). 由于要保存图像,因此可以在保存图像时在图像视图中显示图像,然后显示UIActivityViewController以共享图像。 Without the user having to pick the image through a UIImagePickerViewController. 无需用户通过UIImagePickerViewController选择图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM