我在UISplitViewController
上有旋轉問題。在我的情況下,在調用splitViewController
(這個splitViewController是窗口的根視圖)的現有模式後,顯示另一個視圖。當該模態視圖旋轉時,splitView旋轉不正確。當modalView旋轉時,iPad的UISplitViewController旋轉不好
splitView看起來像旋轉一樣,但DetailViewController
保持它的樣子,並且RootViewController
完全不顯示。它仍然像肖像模式。似乎splitView旋轉,但不是底層視圖(DetailViewController
和RootViewController
)。
我嘗試在modalView上實現willRotateToInterfaceOrientation
,並使用委託調用splitView的willRotateToInterfaceOrientation
方法。
這是我在modalView實現:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
其結果是,在DetailViewController
正確的行爲,但不與RootViewController
。它保持隱藏。在用戶手動旋轉到縱向並返回到橫向後,它將重新出現。但顯然用戶不希望這樣。
這是我做的呈現modalView時:
ModalViewController *modalView = [[ModalViewController alloc] init];
MacProjectAppDelegate *delegate = (MacProjectAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.splitViewController presentModalViewController:modalView animated:YES];
[modalView release];
有沒有一種方法,以顯示在這種情況下,RootViewController
?或者是我的做事不對?
編輯: 似乎所有的意見都沒有按照modalView旋轉。 RootViewController和DetailViewController都沒有旋轉(在兩個ViewController上都沒有調用the didRotateFromOrientation
)。所以現在我假設它不會在設備/ modalView之後旋轉。
您是否試圖從'DetailViewController'中直接顯示您的modalViewController,而不是直接從UISplitView中顯示? –
我試過了,它不工作。到目前爲止,我所做的解決方案是獲取'appDelegate'並獲取splitViewController來調用'willRotateToInterfaceOrientation'兩次。一個在'modalView'的'willRotateToInterfaceOrientation'方法中,一個在'RootViewController'的'willAppear'方法中。 但是這種方法仍然有問題。 'DetailViewController'仍然顯示導航按鈕,就像在縱向模式下一樣。我仍在研究這個。 – Kurotsuki
我有同樣的問題。看看我的解決方案在這裏http://stackoverflow.com/questions/7767302/how-to-inform-the-parent-viewcontroller-about-the-changed-screen-orientation-in/10623628#10623628 – HammerSlavik