2013-07-06 41 views
0

我想通過隱藏UINavigationBar和UIStatusBar使全屏的View(UIBubbleTable實例躺在視圖控制器視圖的頂部)。但由於某些原因黑色空間保持在頂部:隱藏UINavigationBar和UIStatusBar後的視圖頂部的黑色空間

NSLog(@"view frame before:%@", NSStringFromCGRect(self.view.frame)); 
    NSLog(@"view bounds before:%@", NSStringFromCGRect(self.view.bounds)); 
    NSLog(@"bubble table frame before:%@", NSStringFromCGRect(self.bubbleTable.frame)); 
    NSLog(@"bubble table bounds before:%@", NSStringFromCGRect(self.bubbleTable.bounds)); 

    [self.view hideKeyboard]; 
    [[UIApplication sharedApplication] setStatusBarHidden:YES]; 
    self.navigationController.navigationBar.hidden = YES; 
    self.containerView.hidden = YES; 

    [self.view setFrame:[[UIScreen mainScreen] bounds]]; 
    [self.bubbleTable setFrame:self.view.bounds]; 

    NSLog(@"view frame after:%@", NSStringFromCGRect(self.view.frame)); 
    NSLog(@"view bounds after:%@", NSStringFromCGRect(self.view.bounds)); 
    NSLog(@"bubble table frame after:%@", NSStringFromCGRect(self.bubbleTable.frame)); 
    NSLog(@"bubble table bounds after:%@", NSStringFromCGRect(self.bubbleTable.bounds)); 

的NSLog:

2013-07-06 22:05:18.068 KIM[5085:c07] view frame before:{{0, 0}, {320, 504}} 
2013-07-06 22:05:18.068 KIM[5085:c07] view bounds before:{{0, 0}, {320, 504}} 
2013-07-06 22:05:18.069 KIM[5085:c07] bubble table frame before:{{0, 0}, {320, 248}} 
2013-07-06 22:05:18.069 KIM[5085:c07] bubble table bounds before:{{0, 934}, {320, 248}} 
2013-07-06 22:05:18.072 KIM[5085:c07] view frame after:{{0, 0}, {320, 568}} 
2013-07-06 22:05:18.072 KIM[5085:c07] view bounds after:{{0, 0}, {320, 568}} 
2013-07-06 22:05:18.072 KIM[5085:c07] bubble table frame after:{{0, 0}, {320, 568}} 
2013-07-06 22:05:18.072 KIM[5085:c07] bubble table bounds after:{{0, 614}, {320, 568}} 

它的外觀上的模擬器: enter image description here

爲什麼發生這種情況,所有的框架和範圍似乎是正確(0,0)?該怎麼辦?

+0

您是否嘗試過重新啓動xcode和模擬器?設備上是否發生同樣的情況?我在一個乾淨的項目中嘗試了你的代碼,並且完全沒有黑線。 – Yan

+0

可能做產品 - >清潔 – Yan

回答

5

請試試這個API:

[self.navigationController setNavigationBarHidden:YES animated:YES]; 

有一次,我的黑條時從不同的視圖控制器石棉水泥,和上面的API救了我。

+0

也救我... –