MainView.Xib不存在于标签栏应用程序



我是标签栏应用程序的新手,我发现所有的教程都需要在MainView中改变一些东西。但当我创建一个新的标签栏应用程序(在Xcode 4),没有MainView.xib。只有:

FirstViewController_iPhone.xib
第一次…iPad.xib
第二个……iPhone.xib
第二个……iPad.xib

它应该在那里,它失踪了,或者你能告诉我一个教程,不需要界面生成器?

设置主界面的方法在过去几次iOS版本中发生了变化。您可以在项目设置或代码中设置它,默认情况下是这样做的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    UIViewController *viewController1, *viewController2;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPhone" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPhone" bundle:nil] autorelease];
    } else {
        viewController1 = [[[FooFirstViewController alloc] initWithNibName:@"FooFirstViewController_iPad" bundle:nil] autorelease];
        viewController2 = [[[FooSecondViewController alloc] initWithNibName:@"FooSecondViewController_iPad" bundle:nil] autorelease];
    }
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;

}

由于它是一个标签栏应用程序,应用程序在代码中创建了一个UITabBarController,然后将其视图控制器设置为FirstViewController和SecondViewController类的实例。

如果你想要跟随这本书,你可以删除这个方法的内容,并创建一个名为MainWindow的xib。Xib,其中有一个TAB栏控制器和两个子实例,即前面提到的实例。点击你的目标设置,在Summary页面,在iPhone/iPod Deployment Info下,你应该看到一个标签为Main Interface的下拉菜单。将其值设置为MainWindow。

最新更新