UIPopoverPresentationController's delegate's -adaptivePresentationStyleForPresentationController… not called when presenting in compact environments
| Originator: | jason.medeiros | ||
| Number: | rdar://21875745 | Date Originated: | July 17, 2015 |
| Status: | Open | Resolved: | No |
| Product: | iOS | Product Version: | iOS 8.3 (12F70) or iOS 9.0 (13A4293g) |
| Classification: | Other Bug | Reproducible: | Always |
Summary: The goal is to present a UIViewController as a popover in both horizontally compact and regular environments. This is accomplished by using a modalPresentationStyle of UIModalPresentationPopover while the UIViewController's popoverPresentationController's delegate is set to a UIPopoverPresentationControllerDelegate conforming object that returns UIModalPresentationNone from -adaptivePresentationStyleForPresentationController…. The documentation for "UIPopoverPresentationController - Configuring a Popover for Display – Listing 1" shows that you are to configure the popoverPresentationController after calling -presentViewController: <quote> Configuring the popover presentation controller after calling presentViewController:animated:completion: might seem counter-intuitive but UIKit does not create a presentation controller until after you initiate a presentation. In addition, UIKit must wait until the next update cycle to display new content onscreen anyway. That delay gives you time to configure the presentation controller for your popover. </quote> The documentation for UIPopoverPresentationControllerDelegate offers similar advice: <quote> After defining an object that adopts this protocol, assign that object to the delegate property of a UIPopoverPresentationController object. You must present a view controller using the UIModalPresentationPopover style before you can obtain such an object. </quote> If you follow this advice, things work fine if you present a view controller in a horizontally regular environment and then switch to a compact environment. However, if you initially present the view controller in a horizontally compact environment, the delegate is not consulted and the presentation is adapted in the default way (i.e. a fullscreen presentation). If you ignore the advice in the documentation and access and configure the view controller's -popoverPresentationController before you call -presentViewController…, then the adaptive presentation is respected in all situations and environments. Steps to Reproduce: 1. Open the attached sample project in Xcode 7 (beta 3 (7A152u)) 2. Run on an iPhone 6 simulator (iOS 8 or 9) 3. Tap "Present Popover" 4. Notice the fullscreen presentation. Tap "Done" to dismiss. 5. Tap the switch to "Before Presentation" 6. Tap "Present Popover" 7. Notice the popover presentation. 8. Run in the iPad Air 2 simulator. 9. Switch to a horizontally compact environment. 10. Repeat steps 3 through 7. Expected Results: When the view controller's -popoverControllerDelegate is configured after presentation, as the documentation suggests, that the UIPopoverControllerDelegate is consulted for the initial presentation in a horizontally compact environment. Actual Results: The UIPopoverControllerDelegate is not consulted when initally presented in a compact horizontal environemnt. Version: iOS 8.3 (12F70) or iOS 9.0 (13A4293g) Notes: The sample project is using the iOS 9 SDK to demonstate the issue in a the splitview multitasking environment. The documentation for UIPopoverPresentationControllerDelegate does not mention that it conforms to UIAdaptivePresentationControllerDelegate, but it does in the header. Configuration: iPhone 6 Simulator and iPad Air 2 Simulator Attachments: https://dl.dropboxusercontent.com/u/1076749/Radars/Adaptive%20Popovers.zip
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Good catch. It is worth to mention that now popoverPresentationController is not configured (equals nil) until you set myPopoverViewController.modalPresentationStyle = .Popover.
What do you think which approach is proper? Documented one or "intuitive" one?