1
votes

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 :)

1
Could you please clarify: you want to show the same controller twice? As a main view on iPad and at the same time inside of a popover?kovpas
I pushed my pickerController with an Overlay over it. When clicking the library button, I am supposed to have a popoverController appear, but when I initialize it, I run into this error up there. Tell me if you need any more details. ThanksSnaker

1 Answers

2
votes

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 presentViewController or 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:

popOver = [[UIPopoverController alloc] initWithContentViewController:pickerController];

then call one of the two methods to present the popover:

[popover presentPopoverFrom.... permittedArrowDirections: UIPopoverArrowDirectionAny animated:YES];