UIPresentationController changes size when another view controller is displayed on top of it

前端 未结 1 584
别跟我提以往
别跟我提以往 2021-01-01 01:08

I am presenting a modal view controller using UIPresentationController. I am setting the frame of presentedView less than the containView\'s bounds using following method:

相关标签:
1条回答
  • 2021-01-01 01:16

    I encountered the same issue. I couldn't solve it by adding constraints, and -[UIPresentationController containerViewWillLayoutSubviews] is called too late (after the dismiss animation is completed).

    After some time I figured out that the problem seems to be that the presenting controller view is being removed from the view hierarchy when you present with the default UIModalPresentationFullScreen presentationStyle and added again with a full screen size when it has to be shown again.

    In iOS 8, you can use UIModalPresentationOverFullScreen as the presentationStyle when presenting from the smaller controller. The system will not automatically remove the presenting controller's view then. (-[UIViewController viewWillDisappear:] and such, doesn't get called on the presenting controller when you do this though)

    You can also use UIModalPresentationCustom which is available in iOS 7, but then you'll have to provide your own transition animation.

    0 讨论(0)
提交回复
热议问题