2017-04-25 54 views
0

我有一个UIPresentationController在主视图上显示一个固定宽度为300的侧面菜单。然后从侧面菜单中,用户可以打开一个全屏模式视图。当模式视图关闭时,菜单视图会在解散动画期间填充屏幕(这是错误的)。在动画结束时,调用containerViewWillLayoutSubviews,菜单将其宽度更正为300.UIPresentationController直到显示后才调用containerViewWillLayoutSubviews

我执行frameOfPresentedViewInContainerView。我也在菜单视图上执行shouldPresentInFullscreen返回NO(尽管这似乎不影响任何我可以确定的东西)。

为什么在拆散动画之前不调用containerViewWillLayoutSubviews?当它被覆盖并显示时,我应该如何维护菜单视图的宽度?

+1

我认为这个问题可以帮助,http://support.microsoft.com/kb/32792202/uipresentationcontroller-changes-size-when-another-view-controller-is-displayed/33385472#33385472 – riadhluke

+0

谢谢,这确实有助于! – ima747

回答

0

感谢riadhluke指导我UIPresentationController changes size when another view controller is displayed on top of it

我的解决办法是在我的菜单的prepareForSegue

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

这迫使全屏模式演示是在全屏幕,这会导致菜单不被丢失,因此不会在解雇后的动画中重新布置。

相关问题