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

wzb*_*zon 0 iphone fullscreen uitableview uiview ios

我试图通过隐藏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));
Run Code Online (Sandbox Code Playgroud)

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}}
Run Code Online (Sandbox Code Playgroud)

它在模拟器上的外观如何: 在此输入图像描述

为什么会发生这种情况,所有的帧和边界似乎都是正确的(0,0)?该怎么办?

And*_*rew 5

请试试这个api:

[self.navigationController setNavigationBarHidden:YES animated:YES];
Run Code Online (Sandbox Code Playgroud)

当我从不同的视角控制器进行转换时,我曾经拿过黑条,上面的api救了我.