1

我在我的應用程序類UINavigationController(與NIB),我想打開它作爲ModalView。UINavigationController作爲ModalView

我這樣做,那麼:(彩光電是僅此的UINavigationController類)

ColorInfo *InfoScreen = [[ColorInfo alloc] initWithNibName:@"ColorInfo" bundle:[NSBundle mainBundle]]; 
[InfoScreen setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 
[self presentModalViewController:InfoScreen animated:YES]; 

它顯示我一個空UINavigtionController元素。請告訴我,如何在ModalView中打開ColorInfo(作爲UINavigationController),在那裏我將能夠瀏覽? 我想我可以用所有的pushViewController方法完成ColorInfo,然後在ModalView的另一個屏幕上打開它。

告訴我如何達到這個效果。

+0

你繼承的UINavigationController? – Yoeri

回答

2

從你聲明的你已經繼承了ColorInfo中的UINavigationController,這不是你想要的。你想要彩光電是一個UINavigationController的根視圖像這樣

 

ColorInfo *InfoScreen = [[ColorInfo alloc] initWithNibName:@"ColorInfo" bundle:[NSBundle mainBundle]]; 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:InfoScreen]; 
[self presentModalViewController:nav animated:YES]; 
 

我建議你閱讀進一步明晰導航控制器文檔。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

+0

對不起,給了同樣的答案,沒有看到你的: - | 該死的,我需要更快:-) – Yoeri

+0

但InfoScreen已經是UINavigationController,我想實現那裏所有推子控制器。我知道initWithRootViewController,但這可能不是我需要的。爲了使ColorInfo.h更清晰,我有:'@interface ColorInfo:UINavigationController' –

+0

@Konrad Kolasa您仍然可以通過調用self.navigationController並使用該類的各種函數從ColorInfo類執行push和pop。將InfoScreen設置爲UINavigationController的根視圖控制器後,視圖控制器的navigationController屬性將可用。您想要繼承UINavigationController的唯一原因是爲了覆蓋或擴展其當前的功能。 –

1

使用此與InfoScreen控制器和不要繼承的UINavigationController ...

UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:InfoScreen]; 
[navController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 
[self presentModalViewController:InfoScreen animated:YES]; 
+0

與之前的文章相同...我想將ColorInfo作爲UINavigationController –