隐藏UINavigationBar和UIStatusBar后,视图顶部的黑色空间

时间:2013-07-06 18:14:07

标签: iphone ios uitableview uiview fullscreen

我试图通过隐藏UINavigationBar和UIStatusBar来全屏显示View(UIBubbleTable实例位于View控制器视图的顶部)。但由于某种原因,黑色空间仍然位于顶部:

    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)?怎么办?

1 个答案:

答案 0 :(得分:5)

请尝试这个api:

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

当我从不同的视角控制器进行传输时,我曾经得到了黑条,上面的api救了我。