UIPopoverController issue with Split Screen feature on an iPad

I'm playing with the new Split Screen feature of iOS 9 for the iPad Air 2. While my Apps works fine in general in all supported sizes, I do see a weird behaviour of UIPopoverControllers. If my App only gets half of the screen, all Popovers are opened no longer as a popover window, but instead are opened like they would be "presented modally". Which means they take over the whole screen area which is reserved for the App. This is a problem because a popover does not have a "close" or "done" button (you close it by tapping outside of the popover), but a modally presented controller can not be closed without a "done" or "close" button. So while my App is in "half-screen" mode, I can no longer close the popover controllers.


Can I force the iOS to present the popovers as popovers in this case? The half screen has a width of 507 pt, the popovers usually have a width of only 320 pt, so it is plenty of room to still present these as popovers. And if I can not force the iOS to present these as popovers, is there a way to find out if the iOS would present popovers modally, so I can at least add "done" or "close" buttons in this case? Or is this just a bug and will be fixed in the future?

I have the same issue. I guess it's OK that the popover changes to full screen, but what is the correct way to hide a close button when in popover mode, and show it when full screen? The size class doesn't change during these transitions (compact in both cases), so overriding traitCollectionDidChange doesn't help.

>but what is the correct way to hide a close button when in popover mode, and show it when full screen?

The usual close that user's are trained to know is to tap/touch outside the popover. If you need a button, then it's most likely an action sheet, not a po.

Switch to UIPopoverPresentationController (UIPopoverController is deprecated in iOS 9).


Using UIAdaptivePresentationControllerDelegate methods, you will get notified when a transition is happening, which will give you an opportunity to modify the view controllers characteristics as appropriate (i.e. show/hide a navigation bar that contains a close button).

In my case I want my viewcontroller to remain showing as a popover because It shows at a perfect size, when showing as a full modal on iOS9_splitmode it didn't look so nice on the iPad big height.


If you want the popover to keep showing as a popover, instead of showing as modal full screen, you can implement the UIPopoverPresentationControllerDelegate.


This is my code in Swift. I hope I don't forget anything:


//set the modal presentation as popover
let vc : MyViewController = ....
vc.modalPresentationStyle = .Popover

//set the delegate of the popoverPresentationController
if let popoverPresentationController = vc.popoverPresentationController {
     popoverPresentationController.delegate = vc
}


Now implement adaptivePresentationStyleForPresentationController. Basically what it does is ask you which presentation mode he should use once the size class has change. I return None to say "keep using the same presentation", so it will still show as a popover.

class MyViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@available(iOS 8.0, *)
    func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
        return .None
    }
}
UIPopoverController issue with Split Screen feature on an iPad
 
 
Q