How to get reference to UIPopoverController when using adaptive segue?

前端 未结 3 701
别跟我提以往
别跟我提以往 2021-02-07 10:00

In my iOS 7 app, I detected if a segue was a popover via this check in prepareForSegue:

if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]])
         


        
3条回答
  •  自闭症患者
    2021-02-07 10:53

    Elaborating on Joey's answer, which led me to what seems the new manner of achieving what we used to do with UIPopoverController.

    This code in prepareForSegue:Sender:

            UIViewController *destination = segue.destinationViewController;
            UIPopoverPresentationController *ppc = destination.popoverPresentationController;
            ppc.delegate = self;
    

    is a simple way to successfully set your view controller as delegate of a UIPopoverPresentationController much the same as you are probably used to doing with the old UIPopoverController.

    And, of course, while you are at it you'll probably add:

    [destination setPreferredContentSize:CGSizeMake(300.00f, 300.00f)];
    

    if you were in the habit of setting UIPopoverController size here as well.

提交回复
热议问题