0

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?

HeadCode
  • 2,770
  • 1
  • 14
  • 26
Irrd
  • 325
  • 1
  • 6
  • 18

3 Answers3

1

Delegate callback didFinishPickingMediaWithInfo. Simply obtain the path from the info dictionary's UIImagePickerControllerReferenceURL.

more check apple documentation

Nazmul Hasan
  • 10,130
  • 7
  • 50
  • 73
1
func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!)
{

 self.displayImg.image = image

    let imgURL: NSURL = editingInfo.valueForKey("UIImagePickerControllerReferenceURL") as! NSURL

    print(imgURL.absoluteString)

    self.dismissViewControllerAnimated(true, completion: nil)
}
Payal Maniyar
  • 4,293
  • 3
  • 25
  • 51
Jaydeep Vora
  • 6,085
  • 1
  • 22
  • 40
0

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

Community
  • 1
  • 1
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143