如何将UITabBarController添加到窗口

问题描述:

嗨,我有一个窗口和一个tabbar。如何将所有视图控制器添加到TabBar和窗口。我的代码是在这里如何将UITabBarController添加到窗口

UITabBarController *tab = [[UITabBarController alloc] init]; 

UIViewController *first = [[UIViewController alloc] init]; 
UIViewController *second = [[UIViewController alloc] init]; 
UIViewController *third = [[UIViewController alloc] init]; 

//HOW can i add these view controllers to tabbar and hwo to add tabbar to window... 


[self.window makeKeyandVisible]; 

请帮助..谢谢

我是新来的,但我认为这会工作。还有很多东西,所以你可能想检查出来。如果可以的话,我会尽力为你找到一个,但我认为这就足够了。

UITabBarController *tab = [[UITabBarController alloc] init]; 

UIViewController *first = [[UIViewController alloc] init]; 
UIViewController *second = [[UIViewController alloc] init]; 
UIViewController *third = [[UIViewController alloc] init]; 

NSArray *tt = [[NSArray alloc] initWithObjects:first, second, third, nil]; 

tab.viewControllers = [[NSArray alloc] initWithArray:tt]; 

[self.window addSubview:[tab view]]; 
[self.window makeKeyAndVisible];