2012-02-20 143 views
0

我有一個選項卡控制器,其中包含一個導航控制器,其中又包含一個視圖控制器。視圖控制器顯示一個標籤欄和一個導航欄。查看屏幕外

在這個視圖控制器我想添加一個全屏視圖(隱藏標籤欄和導航欄,但離開狀態欄),這是在加載過程中顯示。我有子類的UIView,併成立了一個筆尖文件中的佈局被裝載到這樣的觀點:

- (id)initWithFrame:(CGRect)frame 
{ 
    if (self = [super initWithFrame:frame]) 
    { 
     // Load nib 
     self = [[[NSBundle mainBundle] loadNibNamed:@"FrontpageCountdownView" owner:self options:nil] objectAtIndex:0]; 
    } 
} 

我的視圖控制器中添加這個觀點是這樣的:

// Hide tab bar and navigation bar 
self.tabBarController.tabBar.hidden = YES; 
self.navigationController.navigationBar.hidden = YES; 

// Add loading (frontpage countdown) view 
CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height); 
NFFrontpageCountdownView *countdownView = [[NFFrontpageCountdownView alloc] initWithFrame:frame]; 
[self.view addSubview:countdownView]; 

在我的筆尖的看法大小爲460(全屏,減去狀態欄)。我的問題是,當我將它添加到視圖控制器時,它顯得「更大」。 我會認爲,由於視圖的大小爲460,它應該在將視圖添加到視圖控制器時顯示整個視圖,但它不顯示底部。儘管它是460像素,但它看起來太大了。

有人可以告訴我這是爲什麼嗎?

My view in Interface Builder

編輯

我的觀點看起來如何在Interface Builder:

My view in Interface Builder

如何我的觀點看在模擬器:

My view in the simulator

+0

如果您記錄「框架」尺寸,您會得到什麼值? – Mutix 2012-02-20 09:52:14

+0

如果我登錄'frame',我得到'320.000000 x 460.000000在0.000000; 0.000000'。我已經更新了我的問題,以顯示Interface Builder中的視圖與它在模擬器中的外觀之間的區別。 – simonbs 2012-02-20 12:03:03

+0

我想你必須設置下面一行'view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; ' – pmk 2012-02-20 12:14:35

回答

0

使用self.tabBarController.tabBar.hidden = YES隱藏標籤欄時會發生這種情況。

相反,您應該隱藏它,然後擴展tabBarController的視圖。

CGRect tabBarFrame = self.tabBarController.view.frame; 
tabBarFrame.size.height += self.tabBarController.tabBar.frame.size.height; 
self.tabBarController.view.frame = tabBarFrame; 
self.tabBarController.tabBar.hidden = YES;