如何在视图顶部放置标签栏

时间:2013-09-04 10:44:43

标签: iphone ios uitabbarcontroller

我正在开发一个iPhone应用程序,我想在其上放置标签栏。

这是我的代码

tabBarController = [[UITabBarController alloc]init];
    tabBarController.view.frame= CGRectMake(0, 0, 320, 40);
    NSArray *arr = [[NSArray alloc]initWithObjects:[[DemoView alloc] init], [[DemoView alloc] init], nil];
    tabBarController.viewControllers = arr;

    [tabBarController.view setBackgroundColor:[UIColor whiteColor]];

    [self.view addSubview:tabBarController.tabBar];

但我看不到标签栏。我不是问题所在。

由于

2 个答案:

答案 0 :(得分:0)

你不必采取另一种观点来添加tabBar。您可以直接添加到您的窗口

答案 1 :(得分:0)

此代码对我有用:

UITabBarController *tabC = [[UITabBarController alloc]init];
tabC.tabBar.frame = CGRectMake(0, 0, 320, 70);

NSArray *arr = [[NSArray alloc]initWithObjects:firstObj,secObj, nil];

tabC.viewControllers = arr;

[self.window addSubview:tabC.view];
相关问题