Irrd Irrd - 1 year ago 117
Swift Question

Swift, How to get the image path from UIPickerView in iOS?

In Android there is a way to take the selected image path and display it in our app. Is there any way to do the same thing in iOS too? To select the image from the picker view, take the image path and display in my app?

Answer Source

UIImagePickerControllerOriginalImage returns only the image's data, with no reference to its local storage.

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {

     if let localUrl = (info[UIImagePickerControllerMediaURL] ?? info[UIImagePickerControllerReferenceURL]) as? NSURL {

        print (localUrl)
        //if you want to get the image name 
        let imageName = localUrl.path!.lastPathComponent

for more help see this link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download