0

我对另一个控制器业务中的这个控制器有点困惑。我认为我们可以在没有 initWIthRootViewController 的情况下初始化 UInavigationController。

ViewController *controller = [[ViewController alloc] init];
controller.title = @"ViewController";
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller]; 

有时我想我明白了,但是当我看到这样的事情时,它让我回到了虚无。我已经阅读了文档,但它(对我而言)做得不好。

谢谢

4

1 回答 1

0

Your Navigation controller is managing the display of the items on it's stack. The rootViewController is the first item for it to display, and first item in the stack. It is a bit different to the other VCs in the stack as AFAIK, it can't be popped. There are times when the root view controller holds information that is useful to other VCs in the stack.

I guess Apple could have let you push a view controller during setup, but They decided that the concept of a root view controller is a good one, and I can see how it helps the IB/Storyboard implementation.

于 2012-08-05T16:07:11.910 回答