I am trying to load an image from a photo library using imagePickerView. I updated my plist to access the photo library as shown below for Xcode 8.

After, Updated plist.I can access the photo library. But the Picker image does not load into my image.
My code is:
Note:
The code below is used to work in Xcode 7, not in Xcode 8?
import UIKit
class ViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
let imagePicker = UIImagePickerController()
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}
@IBAction func library(_ sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary) {
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary;
imagePicker.allowsEditing = true
self.present(imagePicker, animated: true, completion: nil)
}
}
Updated code: from rmaddy's answer:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.image = image
}
picker.dismiss(animated: true, completion: nil);
}

Thanks in Advance ....
source
share