2010-09-11 25 views
3

我在我的RootViewController的使用下面的代碼加載一個模態視圖控制器顯示:UINavigationBar的拒絕在模態視圖控制器

[self.navigationController presentModalViewController:accountViewController animated:YES]; 

在accountViewController廈門國際銀行文件,我設置了導航欄。我的MainWindow.xib和RootViewController.xib也有正確的導航欄設置。此外,我的應用程序代表具有設置導航控制器(I假設)正確:

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; 
self.navigationController = aNavigationController; 

[window addSubview:navigationController.view]; 

然而,當我加載我accountViewController的UINavigationBar的是無處可看。是不是可以在模態視圖中顯示UINavigationBar?我打算用它來隱藏後退按鈕,並添加一個正確的按鈕...

回答

6

sha的回答是正確的,但我給出了自己的答案,用代碼示例對其進行了擴展,以便說清楚。

你可能想是這樣的:

- (void)showAccountViewController 
{ 
    AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:@"AccountView" bundle:nil]; 
    ... 
    // Initialize properties of accountViewController 
    ... 
    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController]; 
    [self.navigationController presentModalViewController:navController animated:YES]; 
    [navController release]; 
    [accountViewController release]; 
} 
+1

謝謝澄清 – mootymoots 2010-09-12 20:13:06

1

您需要推不viewController但具有viewController裏面的navigationController。

+0

謝謝你指點我在正確的方向:) – mootymoots 2010-09-12 20:13:22

0

您還可以設置呈現樣式在屬性檢查器「當前上下文」。模態視圖不會覆蓋導航欄。