is there a way NOT to have the popover dismissed when pressing outside it?

后端 未结 3 1461
执笔经年
执笔经年 2020-12-29 14:14

I know the SDK documentation says

Taps outside of the popover’s contents automatically dismiss the popover.

But I\'m sure the s

3条回答
  •  自闭症患者
    2020-12-29 14:47

    There is a very simple and legit solution. In the view controller that presents your UIPopoverController, conform to the UIPopoverControllerDelegate protocol and implement the following delegate method. I just tested this and it does prevent popover to dismiss.

    - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
    {
        return NO;
    }
    

    Just make sure that you have set the delegate of your popover controller to the view controller that implements this.

    You can dismiss the popover by using [popoverController dismissPopoverAnimated:NO]; method.

提交回复
热议问题