2011-04-19 86 views
0

嗨,我有一個窗口和一個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]; 

請幫助..謝謝

回答

0

我是新來的,但我認爲這會工作。還有很多東西,所以你可能想檢查出來。如果可以的話,我會盡力爲你找到一個,但我認爲這就足夠了。

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];