我遇到了一種似乎另有建議的情況。在下面的代碼片段中,如果我刪除了這一行:self.navigationController = nav,那麼根控制器的視圖將不會顯示出來,向我暗示addSubview可能實際上並未保留視圖,如其他建議。任何想法?UIView的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];
}
您的標記答案不正確,原因我在下面評論。 – 2009-06-02 06:31:20