简体   繁体   English

如何在Swift 3.0中获取保存的图像URL

[英]How to get the saved image URL in Swift 3.0

I am trying to get the path of the saved image. 我正在尝试获取已保存图像的路径。 I am running the code on my physical device. 我正在物理设备上运行代码。 I can take the picture but even if I save the picture there is no way for me to get the URL of the picture that is saved. 我可以拍照,但是即使保存图片,也无法获取已保存图片的URL。

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        let photo = info[UIImagePickerControllerOriginalImage] as? UIImage
        self.photoImageView.image = photo

        UIImageWriteToSavedPhotosAlbum(photo!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)

        self.dismiss(animated: true, completion: nil)
    }



    func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) {



    }

As far as I know Apple does not provide an API to select any kind of file like in android with the use of file manager. 据我所知,Apple没有提供使用文件管理器来选择任何类型的文件(例如android中的文件)的API。 If u want to bring up an image in the application you need to open albums and choose the necessary pictures. 如果要在应用程序中显示图像,则需要打开相册并选择所需的图片。 If you still want the concept of file manager as folders, sub-folders and files on your device, you will have to use iCloud storage as it provides the above mentioned directory system as you wish to have. 如果仍然希望将文件管理器作为设备上的文件夹,子文件夹和文件的概念,则必须使用iCloud存储,因为它提供了所需的上述目录系统。

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

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