When dismissing modal displayed over UIPresentationController-based VC parent VC displayed at wrong size

Originator:agiletortoise
Number:rdar://18005149 Date Originated:8/13/2014
Status:Open Resolved:
Product:iOS SDK Product Version:8.0 (12A4345d) and others
Classification:UI/Usability Reproducible:Always
 
Summary:
If a UIPresentationController(PC) is used to present a ViewController(VC) which does not take up the full window, and the VC presents a modal ViewController(ModalVC) – when the ModalVC is dismissed, the VC is first displayed taking up the full window, then "jumps" to it's proper size as defined by the PC.

This behavior is reproducible in all iOS 8 betas up to and including beta 5 on both device and the simulator, both iPad and iPhone.

Steps to Reproduce:
- Launch included sample project.
- Tap "Red Controller" button to present ViewController over partial window, using the included PresentationController class.
- Tap "Blue Controller" button to modally present BlueViewController full screen over the RedController.
- Tap "Dismiss" button in BlueController, and watch.  The window will briefly flash the RedController at the wrong size, then adjust to the size specified by the PresentationController class.

Expected Results:
The ViewController managed by the UIPresentationController should be set to it's proper size BEFORE being displayed during dismissal and not flash at the wrong size.

Actual Results:
The window will briefly flash the ViewController managed by the UIPresentationController at the wrong size (full screen), then adjust to the size specified by the PresentationController class.

Version:
8.0 (12A4345d) and others

Notes:


Configuration:
iOS 8, any beta include at least b5, iPad, iPhone or simulator

Attachments:
'BUG_PresentationController.zip' was successfully uploaded.

Comments

Workaround

This is my workaround – an overridden property in a subclass of UIPresentationController. Not pretty but works fine in my case:

override var presentedView : UIView? {
    let presentedView = super.presentedView

    // HACK: This is a workaround for the bug described in: http://openradar.appspot.com/18005149
    // UIKit changes the frame of the `presentedView` outside of our control. We can change that frame in
    // `containerViewWillLayoutSubviews()` but it's too late in the process - if we do that it's visible that
    // the frame changes without an animation during dismissal.
    presentedView?.frame = frameOfPresentedViewInContainerView

    return presentedView
}
By arkadiusz.holko at Nov. 25, 2016, 10:12 p.m. (reply...)

This bug is still present in iOS 8.1.1.

I'm not sure of a clear workaround, either, since that the time viewDidAppear and updateViewConstraints are called, the partial screen VC still thinks it's full screen, the "jump" to it's proper size has not yet happened, so subviews constraints can get calculated improperly and are not updated after the "jump".

By agiletortoise at Nov. 18, 2014, 6:08 p.m. (reply...)

This vine demos the sample project in action: https://vine.co/v/MY6n6DjEH5J

By agiletortoise at Nov. 18, 2014, 6:08 p.m. (reply...)

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!