UITabBarController裁剪

时间:2012-12-26 12:15:50

标签: objective-c cocoa-touch

button中有viewcontroller加载motherViewController。这似乎工作正常,但由于某种原因,新引入的view非常高,底部的内容被裁剪。

- (IBAction)LoginButton:(UIButton *)sender
{
        FirstViewController *FirstView = [self.storyboard instantiateViewControllerWithIdentifier:@"First"];
        SecondViewController *SecondView = [self.storyboard instantiateViewControllerWithIdentifier:@"Second"];
        ThirdViewController *ThirdView = [self.storyboard instantiateViewControllerWithIdentifier:@"Third"];
        FourthViewController *FourthView = [self.storyboard instantiateViewControllerWithIdentifier:@"Fourth"];
        FifthViewController *FifthView = [self.storyboard instantiateViewControllerWithIdentifier:@"Fifth"];

        FirstView.Username = self.UsernameBox.text;

        UINavigationController *FirstNavController = [[UINavigationController alloc]init];
        [FirstNavController pushViewController:FirstView animated:NO];

        UINavigationController *SecondNavController = [[UINavigationController alloc]init];
        [SecondNavController pushViewController:SecondView animated:NO];

        UINavigationController *ThirdNavController = [[UINavigationController alloc]init];
        [ThirdNavController pushViewController:ThirdView animated:NO];

        UINavigationController *FourthNavController = [[UINavigationController alloc]init];
        [FourthNavController pushViewController:FourthView animated:NO];

        UINavigationController *FifthNavController = [[UINavigationController alloc]init];
        [FifthNavController pushViewController:FifthView animated:NO];


        tabBar = [[UITabBarController alloc]init];    
        tabBar.viewControllers = [NSArray arrayWithObjects:FirstView, SecondView, ThirdView, FourthView, FifthView, nil];
        [self.view addSubview:tabBar.view];

}

View controller

2 个答案:

答案 0 :(得分:1)

我不知道我是不对。但是答案是,您尝试将UIViewController (UITabbarController)添加到ViewController。因此,您需要将其放在view中,例如

tabbar.view.frame = CGRectMake(0, 0, 320, 460);

但是,当我们添加到window时,我唯一不知道它是如何完美定位的。通过为frame设置tabbarcontroller来尝试使用您的代码。

答案 1 :(得分:0)

试试这个 -

 tabBar.tabBar.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;