Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipad - dismissing a UIPopoverController

I have a button inside the content of a UIPopoverController. This button runs a method called myAction.

MyAction has the form

- (void) myAction:(id)sender 

so, myAction receives the id of the caller button.

Now, inside this method I would like to dismiss the UIPopoverController, but the only thing I have is the ID of the caller button. Remember that the button is inside the UIPopoverController.

Is there a way to discover the ID of the UIPopoverController, given the button ID I already have?

thanks.

like image 296
Duck Avatar asked Apr 13 '10 14:04

Duck


1 Answers

Unfortunately no. At least, not within the standard practices. You might be able to travel up the responder stack to find it, but it's a hack, it's buggy, and it's really, really messy.

If you want to dismiss a popover by pushing a button, some place relevant should keep a reference to the popover. Usually that would be the owner of the popover (not the controller showed within the popover). When the button is pressed, it can send a message to the owner controller, which can then dismiss the popover.

You might be tempted to have the controller displayed inside of the popover be the owner of its own popover, but coding this way is brittle, can get messy (again), and may result in retain loops so that neither ever gets released.

like image 86
Ed Marty Avatar answered Sep 30 '22 22:09

Ed Marty