2011-01-13 80 views
0

我有一個應用程序,通過導航控制器內的一組屏幕,然後有一個選項卡控制器,其中一個包含的視圖要顯示一個模式視圖控制器應該是顯示在整個應用程序的頂部(儘管不是全屏)。UINavigationController重疊了一個ModalViewController

這一切都工作正常,但模式窗口部分覆蓋在導航控制器的頂部。我已經嘗試使用self/self.tabBarController/self.navigationController/self.tabBarController.navigationController來調用presentModalViewController,但它們要麼不工作,要麼仍然顯示下面的模式窗口。

我一直在尋找這一整天的答案,其他人似乎有問題,當它重疊,而不是當它沒有。

任何想法?謝謝。 (代碼,截圖如下&視頻)

- (IBAction)add:(id)sender { 
    // create the view 
    AddAttainmentController *addScreen = [[AddAttainmentController alloc] init]; 
    // pass in a selected pupil 
    [addScreen setPupils:[NSMutableArray arrayWithObject:pupil]]; 
    // add the view to a navigation controller 
    UINavigationController *control = [[UINavigationController alloc] initWithRootViewController:addScreen]; 
    // place the navigation controller on the screen 
    [self presentModalViewController:control animated:YES]; 
    // release at the end 
    [control release]; 
    [addScreen release]; 
} 

截圖:http://cl.ly/032v2k0t0N1s1m3H0511(你可以看到導航欄作爲模態窗口幻燈片)http://cl.ly/1h0o453Y3Z051P3S1S37(模態窗口的導航欄是由原始覆蓋)

視頻:http://cl.ly/1e2J3o1q3V1l1j470m12

回答

1

這聽起來像你沒有考慮一些關於使用Apple的視圖控制器類的限制和假設,並且因此導致了未定義的和意外的行爲。

標籤欄控制器希望始終位於控制器層次結構的根部。從類參考:

當部署一個標籤欄界面時,您必須安裝此視圖作爲您的窗口的根。不像其他視圖控制器,標籤欄界面不應該被安裝爲另一個視圖控制器

此外模式視圖控制器(以及與此有關的所有視圖控制器)假定來填充其窗口的孩子。

+0

感謝您的幫助,我根本沒有意識到這一點,似乎是一個不必要的限制。有關替代方案的任何建議? – 2011-01-13 17:37:44

相關問題