环境:xcode4.0,Interface Builder
目的:我想不在MainWindow.xib里创建UITabBarController,改在其他的xib里
步骤: 
1. 创建一个纯正Window Based项目2. 在xxxAppDelegate.h里增加一个viewcontroller属性(MainWindow.xib的东西我没修改)3. 添加一个customTab.xib4. 指定customTab.xib的File's Owner为 xxxAppDelegate5. 在customTab.xib里,从library拖出来一个Tab Bar Controller6. 在customTab.xib里,从library拖出来一个Object,custom class指向xxxAppDelegate7. 关联Tab Bar Controller到Object(即xxxAppDelegate)的viewcontroller启动项目,我发现UITabBar完全没显示出来。请问我哪个步骤出错了

解决方案 »

  1.   

    升级xcode吧,现在都用storyboard了
      

  2.   

    因为默认的window.rootViewController 还是指向的viewController属性。你所设置的那些都没用。
    方法也不只是唯一通过nib文件来实现,你可以用代码来写NSMutableArray *controllers=[NSMutableArray array];FirstViewController *firstVC=[[FirstViewController alloc] init];
    [controllers addObject:firstVC];
    [firstVC release];SecondViewController *secondVC=[[SecondViewController alloc] init];
    [controllers addObject:secondVC];
    [secondVC release];.......
    //创建UITabBarController
    UITabBarController *tabBarController=[[UITabBarController alloc] init];
    [tabBarController setViewControllers:controllers];self.window.rootViewController=tabBarController;
    [tabBarController release];
      

  3.   

    我google好一阵,最后发现确实没法直接通过IB就显示/启动出非MainWindows.xib的UITabBarController,我把总结放在
    http://www.cocoachina.com/bbs/read.php?tid=125671 了。