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?
            Asked
            
        
        
            Active
            
        
            Viewed 1,448 times
        
    3 Answers
1
            
            
        Delegate callback didFinishPickingMediaWithInfo. Simply obtain the path from the info dictionary's UIImagePickerControllerReferenceURL.
 
    
    
        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
- 
                    let localUrl = (info[UIImagePickerControllerMediaURL] ?? info[UIImagePickerControllerReferenceURL]) as? NSURL – Uma Achanta Jul 26 '17 at 11:39
- 
                    see this https://github.com/digipost/ios/blob/master/Digipost/UploadImageController.swift – Anbu.Karthik Jul 26 '17 at 11:40
- 
                    Anbu - thanks for the link. Did I need to add anything in info.plist – Uma Achanta Jul 26 '17 at 11:52
 
    