Gre*_*reg 4 iphone uitableview uinavigationcontroller ios rootview
为什么didFinishLaunchingWithOptions方法中需要以下行?
self.window.rootViewController = self.navigationController;
Run Code Online (Sandbox Code Playgroud)
也就是说,在Interface Builder中,MainWindow XIB中已经有导航控制器,它的导航栏和RootViewController在它的层次结构中.
整个方法的副本供参考:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在MainWindow.xib中还有一件事你没做:将导航控制器的视图添加到窗口.
这条线
self.window.rootViewController = self.navigationController;
Run Code Online (Sandbox Code Playgroud)
做到了那一点.替代方案(以及我们在iOS 3中编写的内容)是:
[self.window addSubview:self.navigationController.view];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11454 次 |
| 最近记录: |