2011-12-29 72 views

回答

3

创建要使用UIViewController S的NSArray。然后实例化一个UITabBarController并将viewControllers属性设置为此数组。然后将tabBarControllerview添加到窗口。所有这些都应该在AppDelegate.m文件中完成。例如:

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 

    UIViewController *vc1 = [[UIViewController alloc] init]; 
    UIViewController *vc2 = [[UIViewController alloc] init]; 
    CustomViewController *vc3 = [[CustomViewController alloc] init]; 

    NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil]; 
    [vc1 release]; [vc2 release]; [vc3 release]; 

    UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
    [tabBarController setViewControllers:viewControllers]; 

    [window addSubview:[tabBarController view]]; 
    [window makeKeyAndVisible]; 

    return YES; 
} 
相关问题