如何使用Frame创建UITabviewcontroller

时间:2012-05-28 05:52:41

标签: ios5

我有一个以编程方式使用UItabviewcontroller的代码,但是如何创建它的框架,因为我在我的应用程序中使用子视图,我需要x,y宽度和高度坐标。

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

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;

1 个答案:

答案 0 :(得分:0)

当您使用ios5标记问题时,我认为您的应用仅在ios5上运行。如果我理解你,你想在另一个视图控制器视图中显示tabBarController。

在5.0之前,这是不可能的,没有一些非常丑陋的黑客攻击。但是对于iOS5.x,现在有一个API。查看“实现容器视图控制器”中的UIViewController文档。您必须将tabBarController设置为当前视图控制器的子视图控制器。您可以分配您想要的框架,只需将其添加到视图中。