1

我的应用程序类 UINavigationController(带有 NIB)中有我想将其作为 ModalView 打开。

我这样做:(ColorInfo 就是这个 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 中的另一个屏幕上打开它。

告诉我如何达到这个效果。

4

2 回答 2

2

根据您所说,您在 ColorInfo 中继承了 UINavigationController,这不是您想要的。您希望 ColorInfo 像这样成为 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

于 2012-05-03T18:11:56.350 回答
1

将此与 InfoScreen 控制器一起使用,并且不要继承 UINavigationController ...

UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:InfoScreen];
[navController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:InfoScreen animated:YES];
于 2012-05-03T18:17:09.780 回答