1

我有一個UITabBarController添加一個viewController,但定位關閉。屏幕頂部有大約20px的間隙,並且加載的viewController的底部被隱藏。如何移動調整加載的viewController的大小?UITabBarController查看位置和大小

viewController = [[FlashCardViewController alloc] initWithNibName:@"FlashCardViewController" bundle:[NSBundle mainBundle]]; 
viewController.view.bounds = [[UIScreen mainScreen]bounds]; 
//viewController.view.alpha = 0.0; 
//[self.view addSubview:viewController.view]; 

tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; 
tabBarController.viewControllers = [NSArray arrayWithObject:viewController]; 
tabBarController.view.alpha = 0.0; 
[self.view addSubview:tabBarController.view]; 

我試過這兩個但沒有運氣。

tabBarController.view.bounds = [[UIScreen mainScreen] bounds]; 
tabBarController.view.frame = [[UIScreen mainScreen] bounds]; 

這不是我真正想要做的。我想將它們設置爲tabBarController查看窗口大小和位置。

回答

5

我結束了手動創建框架矩形:

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

感謝您的提示。我可以通過在viewWillAppear方法內使用self.tabBarController.view.frame = [[self view] frame]來快速計算出此代碼的數字。 – pulkitsinghal 2011-12-29 16:22:06

1

20像素聽起來像狀態欄的高度可疑。

我建議你打開你的FlashCardViewController.xib文件,並仔細檢查你的視圖下的「模擬界面元素」,你沒有選擇任何「狀態欄」。然後應該將視圖向上移動20個像素。

+0

我做您的建議改變,偉大的想法,但沒有我的屏幕上有任何影響。我認爲這個問題與tabBarController有關。大概百分之七十五的標籤欄在底部被切斷。 – Bryan 2009-08-25 16:28:44

2
CGRect screenArea = [[UIScreen mainScreen] applicationFrame]; 

tabBarController.view.frame = CGRectMake(0,0,screenArea.size.width,screenArea.size.height);