2012-05-28 33 views
0

我有一个代码为UItabviewcontroller使用编程方式,但如何创建其框架,因为我在我的应用程序中使用我需要x,y宽度和高度坐标的子视图。我们可以使用UITabBarController * tabBarController = [[UITabBarController alloc] init];如何创建与框架UITabviewcontroller

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

UIView *v1 = [[UIView alloc] init]; 
UIView *v2 = [[UIView alloc] init]; 

vc1.title = @"vc1"; 
vc2.title = @"vc2"; 

tabBarController.viewControllers = [[NSArray alloc] initWithObjects:vc1, vc2, nil]; 

self.view = tabBarController.view; 

回答

0

当你用ios5标记你的问题时,我想你的应用程序只运行在ios5上。如果我理解你是对的,你想在另一个视图控制器视图中显示tabBarController。

在5.0之前,这是不可能的,没有一些非常丑陋的黑客。但是对于iOS5.x,现在有一个API。查看'Implementing a Container View Controller'中的UIViewController文档。您必须将tabBarController设置为当前视图控制器的子视图控制器。您可以指定您想要的框架,并将其添加到您的视图中。