0
votes

I'm trying to make a segue from a UIImagePickerController to another view controller.

I have tried a push segue, because I knew that UIImagePickerController was a subclass of UINavigationController, but it didn't work. The error is "Push segues can only be used when the source controller is managed by an instance of UINavigationController."

Now I try a modal segue, but when it occurs, the screen goes black.

Is there a link between the two problems, and how can I do please ?

1

1 Answers

2
votes

You cannot perform segue directly from a UIImagePickerController.

Try to add a push segue from the view controller that instantiates the UIImagePickerController to the target VC.

Now implement UIImagePickerControllerDelegate method didFinishPickingMediaWithInfo: in your source VC and inside that method call self performSegueWithIdentifier: sender: with the segue identifier of the segue, you have created lately.

Of course, you need to set an identifier for the segue and add UINavigationControllerDelegate, UIImagePickerControllerDelegate protocol references in your source VC header interface.

Also you might need to implement prepareForSegue: method in your source VC if you need to pass some data (such as image information) to the target VC.