2017-04-25 56 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; 
} 

這迫使全屏模式演示是在全屏幕,這會導致菜單不被丟失,因此不會在解僱後的動畫中重新佈置。

相關問題