UINavigationController incorrectly informs children of new size in multitasking environment.

Originator:matt.yohe
Number:rdar://22243353 Date Originated:11-Aug-2015 09:34 PM
Status:Open Resolved:
Product:iOS Product Version:iOS 9 Beta 13A4325c
Classification:Serious Bug Reproducible:Always
 
Summary:
Incorrect behavior is observed on an iPad when a popover is presented, and the user transitions from regular to compact size class. Upon transition between these size classes, UIPresentationController’s delegate is given a chance via  presentationController(_: , viewControllerForAdaptivePresentationStyle) to return a view controller wrapped in a UINavigtationController. When doing this, it is clear the child in the now modally presented view controller (which is now inside a UINavigationController) is given an incorrect size in viewWillTransitionToSize(_:withTransitionCoordinator:). This behavior is not present if not wrapping the view controller in a UINavigationController.

Steps to Reproduce:
1. Create a Universal App.
2. Create a button that can present a view with a presentation style of .Popover
3. Respond to the delegate of the popoverPresentationController’s method presentationController(_:viewControllerForAdaptivePresentationStyle) with the presentationController’s presentedViewController wrapped in a UINavigationController
4. Launch the app on an iPad in landscape.
5. Tap the button to present a popover.
6. Transition into 50/50 Split View


Expected Results:
The size reported to the presented view controller via viewWillTransitionToSize(_:withTransitionCoordinator) should be accurate

Actual Results:
Inaccurate sizes are given.

Version:
iOS 9 13A4325c

Notes:
I've attached a sample project that demonstrates this issue, and the issue of collection view cell sizing that allowed me to stumble onto it. It also contains a screenshot of running the broken and fixed schemes.

It contains two schemes. BrokenTransitionToSizeBroken and BrokenTransitionToSizeFixed. The only difference is that ...Broken defines a flag that responds to presentationController(_:viewControllerForAdaptivePresentationStyle) with the view wrapped in a UINavigationController. The Fixed version simply does not wrap this controller and expected behavior is observed both visibly, and in the console where I'm logging out the expected size.

Configuration:
iPad Air 2 Simulator

Attachments:
'BrokenTransitionToSize.zip' was successfully uploaded.

Comments

https://github.com/mattyohe/rdar-22243353


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!