在iPad编程指南中,它提供了以下代码示例,用于指定将在SplitView中使用的两个视图(firstVC和secondVC)...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MyFirstViewController* firstVC = [[[MyFirstViewController alloc]
initWithNibName:@"FirstNib" bundle:nil] autorelease];
MySecondViewController* secondVC = [[[MySecondViewController alloc]
initWithNibName:@"SecondNib" bundle:nil] autorelease];
UISplitViewController* splitVC = [[UISplitViewController alloc] init];
splitVC.viewControllers = [NSArray arrayWithObjects:firstVC, secondVC, nil];
[window addSubview:splitVC.view];
[window makeKeyAndVisible];
return YES;
}
但是当我在Xcode中实际创建一个新的SplitView项目时,我没有看到任何代码表明应该将默认的rootView和detailView视图添加到SplitView中。我在哪里可以找到它?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch
rootViewController.managedObjectContext = self.managedObjectContext;
// Add the split view controller's view to the window and display.
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];
return YES;
}
我是iPhone OS编程的新手,我只是想了解这一切是如何运作的。在此先感谢您的帮助!我现在要继续研究这个问题。
答案 0 :(得分:2)
这是因为链接已经在* .nib文件中设置了。如果您不想依赖* .nib自动执行此操作,您仍然可以使用.viewControllers
方法。