选项卡式应用程序中的MainWindow.xib

时间:2012-01-26 16:04:40

标签: ios xcode

我是IOS领域的初学者,我发现有些难以理解的老教程,包括甚至不到4-5个月的视频。主要原因是我正在使用xcode 4.2.1,大部分教程都基于早期版本。所以这有点让我感动一些我想要解决的例子。

主要问题在于MainWindow.xib文件,在那里我找到了一些很好的教程和视频,了解如何手动重建MainWindow.xib。我需要说我遵循了这一点并善于重新创造它。另一方面,我有一个问题,无论我需要在除空应用程序之外工作的新项目,是否可以像为空应用程序创建的那样创建MainWindow.xib文件,或者它会有所不同用于选项卡式应用程序或其他一些应用程序。

有人可以对此有所了解!

由于 MAKS

2 个答案:

答案 0 :(得分:2)

以下代码用于创建UItabbar。 在xcode 4.2.1中,没有创建任何main.xib,因为你需要通过创建tabbar然后调用它来动态地(代码)应用它。

-(void)applicationDidFinishLaunching:(UIApplication *)application {

    // Add the tab bar controller's current view as a subview of the window
    tabBarController.delegate=self;
    tabBarController=[[UITabBarController alloc] init];

    mainDashBoard=[[DashBoard alloc] initWithNibName:@"DashBoard" bundle:nil];
    mainSearchView=[[SearchView alloc] initWithNibName:@"SearchView" bundle:nil];
    mainMoreView=[[MoreView alloc] initWithNibName:@"MoreView" bundle:nil];

    UINavigationController *nvCtr0=[[[UINavigationController alloc] init] autorelease];
    UINavigationController *nvCtr1=[[[UINavigationController alloc] initWithRootViewController:mainDashBoard] autorelease];
    UINavigationController *nvCtr2=[[[UINavigationController alloc] initWithRootViewController:mainSearchView] autorelease];
    UINavigationController *nvCtr3=[[[UINavigationController alloc] initWithRootViewController:mainMoreView] autorelease];
    UINavigationController *nvCtr4=[[[UINavigationController alloc] init] autorelease];//[[[UINavigationController alloc] initWithRootViewController:nil] autorelease];

    tabBarController.viewControllers=[NSArray arrayWithObjects:nvCtr0,nvCtr1,nvCtr2,nvCtr3,nvCtr4,nil];

    nvCtr0.tabBarItem.enabled=NO;
    nvCtr4.tabBarItem.enabled=NO;

    [window tabBarController.view];
}

实施您的应用程序可能会有所帮助

答案 1 :(得分:1)

使用点按栏制作应用程序的方法有很多种。我更喜欢在代码中创建标签栏控制器,并使用xib执行不同选项卡中显示的视图控制器的界面。但有时我觉得在代码中完全创建接口更实用。

我会在UITabBarController中分配并初始化AppDelegate,并将我需要的视图控制器分配给标签栏控制器。然后,您必须将窗口的rootViewController分配给选项卡栏控制器。