iosuipresentationcontroller

UIPresentationController not calling containerViewWillLayoutSubviews until after display


I have a UIPresentationController displaying a side menu over the main view with a fixed width of 300. Then from the side menu the user can open a full screen modal view. When the modal view is dismissed the menu view fills the screen during the dismissal animation (this is wrong). At the end of the animation containerViewWillLayoutSubviews is called and the menu corrects it's width to 300.

I do implement frameOfPresentedViewInContainerView. I am also implementing shouldPresentInFullscreen returning NO on the menu view (though this seems to not affect anything I can really determine).

Why isn't containerViewWillLayoutSubviews called before the dismssal animation? How should I be maintaining the menu view's width when it is covered and revealed?


Solution

  • Thanks to riadhluke for directing me to UIPresentationController changes size when another view controller is displayed on top of it

    My solution is in my menu's prepareForSegue

    UIViewController *destination = [segue destinationViewController];
    if (destination.modalPresentationStyle == UIModalPresentationFullScreen) {
        destination.modalPresentationStyle = UIModalPresentationOverFullScreen;
    }
    

    Which forces fullscreen modal presentations to be Over full screen, which causes the menu not to be lost, and therefore not re laid out post dismissal animation.