I'm making an iOS app using swift3 on xcode8.
My storyboard is this ( storyboard ).
If I click the button on the third TableViewController from the left, the fourth one will appear. The fourth one is a ViewController to choose library or camera to place a photo onto the imageView on the third TableViewController.
I write the function below in the fourth ViewController's file. The function is a method called when a photo is taken or chosen.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
if info[UIImagePickerControllerOriginalImage] != nil {
DispatchQueue.main.async {
let navigationController = self.presentingViewController as! UINavigationController
let originVc = navigationController.topViewController as! SettingTableViewController
originVc.image = image
self.dismiss(animated: true, completion: nil)
}
}
picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
When this is run, let navigationController = self.presentingViewController as! UINavigationController
part is highlighted, and says Thread 1: signal SIGABRT
. And also the error Could not cast value of type '[APPNAME].ViewController' to 'UINavigationController' (0x10f85c4a8).
is shown(*[APPNAME] is my app name).
Do you know anything about this?
Thank you in advance!