2011-05-25 56 views
2

我有具有以下結構的應用:UINavigationController的旋轉問題,模態對話框

UIWindow 
    -- GlobalNavigationController.view (subclasses UIViewController) 
     -- UIView 
     -- UINavigationController.view 

GlobalNavigationController轉發所有旋轉和生命週期事件(viewWillAppear中,willRotateToInterfaceOrientation等),導航控制器。

一切都運行得很好,直到你:

  1. 打開一個模式對話框
  2. 旋轉到橫向(或另一方向)
  3. 關閉對話框。

在這一點上,似乎UINavigationController中的底層視圖沒有通知一些旋轉事件。

你得到的意見是這樣的:

Screenshot after rotation

任何想法? 由於

+0

更新:willRotateToInterfaceOrientation沒有被稱爲顯示模態對話框時的GlobalNavigationController – 2011-05-25 18:10:10

回答

0

它原來是一個問題,導航控制器沒有一個parentViewController屬性集。愛無證陷阱...

簡單的解決辦法是在導航控制器初始化後,把這個:

[_navigationController setValue:self forKey:@"_parentViewController"]; 

道具PrimaryFeather爲理念: Modal View Controller Won't Start in Landscape Mode

0

在您的模態視圖控制器,嘗試建立以下內容:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    [self.parentViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 
} 

這發出該視圖旋轉到它的父,它是呈現的模式窗口的視圖消息

0

我遇到了一個與我正在開發的應用類似的問題。事實證明,我的問題是我沒有正確指定我的控件(例如頂部工具欄)如何增長和拉伸。

如果問題不是代碼問題,看看IB,看看如果你定義自動增長等