Custom presentation using Auto Layout breaks on fullscreen presentation

Number:rdar://47946890 Date Originated:February 10 2019, 2:54 AM
Status:Open Resolved:false
Product:iOS + SDK Product Version:Xcode Version 10.1 (10B61) / iOS 12.1.3
Classification:Other Bug Reproducible:Always


It is expected that custom `UIPresentationController` subclasses can lay out their content using Auto Layout, modulo the nuts and bolts of custom transitions or the content being driven by manual layout. Any lack of such a capability isn't documented, and DevPubs encourages it:

> Apps that use auto layout should not need to do anything because the auto layout mechanism resizes views as needed.

Adding constraints when setting up custom views in the `containerView` during `presentationTransitionWillBegin` works great.

The problem occurs when doing modal presentations on top of this custom transition. For instance, a subsequent full-screen presentation does something unexpected to move its `presentingViewController.view` into its hierarchy, which breaks any constraints.

Steps to Reproduce:

1. Download and open the attached sample project, `Layout.xcodeproj`.
2. Run the "Layout" scheme on any iOS simulator or device.
3. Tap "Show Modal".
4. Tap "Fullscreen Top Me".
5. Observer.

A video of the issue is attached.

Expected Results:

The full-screen view presents over the card view seamlessly.

The full-screen view dismisses to reveal the the card view seamlessly.

Actual Results:

The card view jumps to an unexpected position on-screen as the full-screen presentation begins.

The card view jumps again to another unexpected position on-screen as the full-screen dismissal begins.

The card view disappears entirely as the full-screen dismissal ends.


Xcode Version 10.1 (10B61)

iOS 12.1.3




In the attached sample project, uncomment CardPresenting.swift:37-39 for a workaround. Using `containerViewWillLayoutSubviews` felt wrong to me, as there's nothing explicit trying it to nested and presentation. If that is a fine place, or there is a better place, that should exist in the documentation.

Additionally, I suspect stealing back the view is a bad idea, but have no simple way to prevent re-activating the constraints in an invalid way. The workaround at least works as I'm expecting.



Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!