I’m currently facing an issue with my UIPopovercontroller.
Here are the facts, I’ve got a class : ImagePickerViewController (inheriting from a BaseViewController) containing two property :
@property (nonatomic, retain) UIImagePickerController *pickerController;
@property (nonatomic, retain) UIPopoverController *popOver;
I also apply an overlay on the pickerController which is presented like this :
[self presentViewController:pickerController animated:NO completion:nil];
And when I want to show an image library through a UIPopoverController on iPad :
popOver = [[UIPopoverController alloc] initWithContentViewController:pickerController];
I get this error :
***Terminating app due to uncaught exception ‘NSGenericException’, reason : ‘the content view controller argument must be the root of its
associated view controller hierarchy.’
I’ve already seen this topic but it didn’t really help.
So I thought that presenting pickerController made it the root by looks like it isn’t.
Any help welcomed 🙂
The problem is that you are trying to display the same pickerController twice, at the same time. You can’t do that. Either present it as a modal view controller using
presentViewControlleror present it in a popover. Don’t try to do both.To show it in the popover, start with the line you have to create the popover:
then call one of the two methods to present the popover: