2010-06-24 41 views
3

我一直在試圖將此UINavigationController添加到我的表單的子視圖中......我所得到的只是一個大灰色屏幕。將UINavigationController添加到iPhone上的子視圖

LiteViewController *lite = [[LiteViewController alloc] initWithNibName:@"LiteViewController" bundle:nil]; 
[self.view addSubview:lite.navigationController.view]; 

它應該添加一個全屏導航控制器到當前視圖。

回答

0

您可能需要makeKeyAndVisible調用。

+0

據我瞭解,該窗口是可見的,因爲我可以添加其他的東西給子視圖,它會工作......眼前這個navigationController讓我頭疼。 – 2010-06-24 21:37:30

+0

我剛剛開始使用iPhone開發,但是我見過的所有示例都將導航控制器直接添加到UIWindow而不是UIView。也許,鑑於這個控制的全屏幕性質,它想要被添加到窗口?請參閱Apple的文檔:http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html#//apple_ref/doc/uid/TP40007457-CH103-SW1 – 2010-06-24 21:56:55

1

我發現一個帖子,UINavigationController not showing the Root View controller,這對我很有用。

基本上你還需要設置navigationController的視圖...

[self.view addSubview:navigationController.view]; 
[navigationController setView:[[navigationController.viewControllers objectAtIndex:0] view]]; 
相關問題