我遇到了一个似乎表明相反的情况。在下面的代码片段中,如果我删除这行代码:self.navigationController = nav,那么根控制器的视图将不会显示出来,这让我觉得addSubview可能并没有像其他人所说的那样保留视图。有什么想法吗?
- (void)applicationDidFinishLaunching:(UIApplication *)application {
self.testViewController = [[TestViewController alloc] initWithNibName:@"TestView" bundle: [NSBundle mainBundle]];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.testViewController];
self.navigationController = nav; //<-- if this line is removed, test view won't show up
[window addSubview:nav.view];
[nav release];
}