Present UIPopoverController from inside a modally presented view controller

1.6k views Asked by At

Is it impossible to present a popover controller from a view controller that's presented as UIModalPresentationFormsheet? or am I missing something?

This code works fine on a non-modal view controller, and displays the popover correctly.(WEPopoverController is a custom implementation from here.)

    GenericDataTableViewController *genericDataController = [[GenericDataTableViewController alloc] initWithNibName:@"GenericDataTableViewController" bundle:[NSBundle mainBundle]];

    genericDataController.dataSource = [NSMutableArray arrayWithObjects:@"asli", nil];
    genericDataController.delegate = self;
    genericDataController.contentSizeForViewInPopover = CGSizeMake(300, 46 * [genericDataController.dataSource count]);

    self.popoverController = [[[WEPopoverController alloc] initWithContentViewController:genericDataController] autorelease];
    self.popoverController.delegate = self;
    [self.popoverController presentPopoverFromRect:((UIButton *)sender).frame
                                            inView:self.view
                          permittedArrowDirections:UIPopoverArrowDirectionUp
                                          animated:YES];
    [genericDataController release];

But when I put this inside the modal view controller, this presents the popover below the modal controller, i.e. on the view controller that presents the modal one. So it cannot be seen by the user.

How can I solve this?

1

There are 1 answers

1
aslı On BEST ANSWER

The answer is explained in the comments of the question but I'm summarizing it here for a cleaner Q&A.

There aren't any restrictions about displaying a popover controller from inside a form sheet, if your popover controller is UIPopoverController. My problem was due to the implementation of WEPopoverController.

So, sacrifice the visual experience and continue with the good old UIPopoverController.