So I am inside a navigation controller and would like to present an image picker upon a button press. That works fine, but when I dismiss the picker it throws me back to the root view controller, and not where I want to process the image.
This is my code:
@IBAction func attachPhotoButtonPressed(sender: UIButton) {
imagePicker.sourceType = .SavedPhotosAlbum
presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
print("Success")
} else{
print("Something went wrong")
}
self.dismissViewControllerAnimated(true, completion: nil)
}
I already looked at these questions, but didn't find a fix. (Not an objective-C guy)
Pushing a navigation controller is not supported- performing segues
presenting ViewController with NavigationViewController swift