2012-12-26 43 views
0

我有一个buttonviewcontroller加载一个motherViewController。这似乎是正常工作,但由于某种原因,新引入的view是如此之高,底部的内容被裁剪。UITabBarController裁剪

- (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

回答

1

我不知道是否我是正确与否。但是,这里的答案是,您正试图将UIViewController (UITabbarController)添加到您的ViewController。所以,你需要在你的view位置,例如

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

但是,只有我不知道它的它是如何完美的位置,当我们增加window事情。通过为您的tabbarcontroller设置frame来试试您的代码。

+0

工作像一个魅力,但有没有其他方式来实现这一目标,而不硬编码的位置和尺寸? –

+1

尝试'CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);' – arthankamal

+0

太棒了!有效。谢谢! –

0

试试这个 -

tabBar.tabBar.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin; 
+0

尝试过,但没有任何区别。不过谢谢你的建议。 –