开发者

How do I dismiss other UIPopoverControllers when presenting a new one?

If I have several buttons that launches the same popovers, how can I dismiss the an already visible popover before displaying the new one?

I have a local variable self.popover that is set to the current popovercontroller; i check this popover variable to see if it is visible; if it is visible then I dismiss it and then present the new one, 开发者_如何学JAVAbut the new one doesnt become visible until I touch it twice.


Try dismissing the existing popover using [myPopover dismissPopoverAnimated:NO]


The reason this is happening is that by default your popover dismisses itself any time a touch occurs outside the popover itself; the touch event itself never gets propagated to the button as it "belongs" to the UIPopoverController. Once this occurs, you have to touch the button again to re-pop.

The best fix would be to retain a pointer to the UIPopoverController, and send an NSArray of the buttons you wish to dismiss/pop popovers from to the controller.

Then in the handler for each of these, check whether a popover is present. If so, dismiss it, and pop the popover for the button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜