UIContentContainer and propagating size changes to child view controllers

Originator:gspiers
Number:rdar://33396970 Date Originated:19/07/2017
Status:Open Resolved:
Product:iOS UIKit Product Version:10.3
Classification:Bug Reproducible:Always
 
Area:
UIKit

Summary:
In the attached project there is one view controller acting as a container view controller that embeds a child view controller.

When the child view controller changes it's preferredContentSize the container gets a call back (preferredContentSizeDidChangeForChildContentContainer:) because it acts as a UIContentContainer.

What I'd like to do is change the size of the child view controller animated (simple enough as I can just change the constraints). But also allow the child view controller to know that it's size is changing. Unfortunately just changing the size of the view doesn't call viewWillTransitionToSize:withTransitionCoordinator: on the child.

The docs seem to suggest this should happen automatically:

"This method (viewWillTransitionToSize:withTransitionCoordinator:) is called when the view controller's view's size is changed by its parent (i.e. for the root view controller when its window rotates or is resized)."

If this isn't the case for custom container view controllers and we manually need to call that when making the size change then I have another problem in that I need to construct a UIViewControllerTransitionCoordinator but there isn't any public concrete class in UIKit and would have to make my own. 

The docs aren't really clear on what is required to create one yourself and even say "Typically, you do not adopt this protocol in your own classes." and for UIViewControllerTransitionCoordinatorContext it even says "Do not adopt this protocol in your own classes."

I notice that for a UIPopoverPresentationController when the preferredContentSize changes of the presented controller it calls the method viewWillTransitionToSize:withTransitionCoordinator: and the coordinator is of type _UIViewControllerNullAnimationTransitionCoordinator. Would it be possible to have this be made public so we can handle similar preferredContentSize changes in our custom container view controllers?

Thank you.

Steps to Reproduce:
Run sample project and notice that viewWillTransitionToSize:withTransitionCoordinator: on the ChildViewController is not called.

Expected Results:
viewWillTransitionToSize:withTransitionCoordinator: should be called, if possible automatically on the size change made by the parent. And if not automatically it would be nice to have a public way to construct a UIViewControllerTransitionCoordinator.

Observed Results:
Animation setup in ChildViewController's viewWillTransitionToSize:withTransitionCoordinator: doesn't run.

Version:
iOS 10.3

Sample project:
https://github.com/gspiers/radar_33396970

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!