Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPopovercontroller Parent?

How can "perform selector" to the parentviewcontroller of the uipopovercontroller? I have uipopovercontroller lanuched from uiviewcontroller, and this uipopovercontroller includes other uiviewcontroller. I can't seem to reach the parent view controller from either the popover or the "internal" view controller.

I hope i'm being clear...

BTW - parentViewcontroller doesn't work...

Thanks!

like image 821
Avi Tsadok Avatar asked Feb 09 '11 22:02

Avi Tsadok


1 Answers

There's no way to do this directly with UIPopoverController. You're going to have to probably pass a reference to your parent view controller to the view controller you're managing with a popover controller:

// Assumes these calls are made from within a view controller and that
// MyViewController has a property called previousViewController

MyViewController * myViewController = [[[MyViewController alloc] init] autorelease];
myViewController.previousViewController = self;
UIPopoverController * popoverController = [[[UIPopoverController alloc] 
    initWithContentViewController:myViewController] autorelease];

UIBarButtonItem * rightBarButtonItem = self.navigationItem.rightBarButtonItem;
[popoverController presentPopoverFromBarButtonItem:rightBarButtonItem
                          permittedArrowDirections:UIPopoverArrowDirectionDown
                                          animated:YES];

Something like that, but the important point is that your view controller (managed by the popover controller) has to grab a reference to your parent view controller before you present the popover.

like image 149
CIFilter Avatar answered Oct 05 '22 21:10

CIFilter