iOS7无法隐藏tabbar、黑条

标签 ios objective-c ios7 hidden tabbar

我想在滚动 Collection View 时隐藏我的标签栏,代码是

 #pragma mark - UIScrollViewDelegate
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    [self makeTabBarHidden:YES];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self makeTabBarHidden:NO];
}

- (void)makeTabBarHidden:(BOOL)hide
{
    if ( [self.tabBarController.view.subviews count] < 2 )
    {
        return;
    }
    UIView *contentView;
    UIView *bradeView = [self.tabBarController.view.subviews objectAtIndex:2];

    if ( [[self.tabBarController.view.subviews objectAtIndex:0] 
             isKindOfClass:[UITabBar class]] )
    {
        contentView = [self.tabBarController.view.subviews objectAtIndex:1];
    }
    else
    {
        contentView = [self.tabBarController.view.subviews objectAtIndex:0];
    }
    //    [UIView beginAnimations:@"TabbarHide" context:nil];
    if ( hide )
    {
        contentView.frame = self.tabBarController.view.bounds;
    }
    else
    {
        contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
                                 self.tabBarController.view.bounds.origin.y,
                                 self.tabBarController.view.bounds.size.width,
                                 self.tabBarController.view.bounds.size.height -
                                    self.tabBarController.tabBar.frame.size.height);
    }

    self.tabBarController.tabBar.hidden = hide;
    bradeView.hidden = hide;
}

但在 iOS7 中,当标签栏被隐藏时,有一个黑色的栏不会消失。如何在 iOS7 中隐藏标签栏?

最佳答案

在 Storyboard中,选择要为其隐藏选项卡栏的 View Controller ,转到属性检查器,然后在“ View Controller ”部分 >“扩展边缘”中选择“底部栏”下的复选框。

如果您的栏是不透明的,还请选择 Under Opaque Bars。

关于iOS7无法隐藏tabbar、黑条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20092176/

相关文章:

objective-c - OSX-iOS : Detect iOS device connection type (wired/wireless)

ios7 - 在 UIImagePickerController 中启用 iOS 7 相机效果

ios - SpriteKit : Count of SKSpriteNodes on screen

iphone - 我似乎在使用 ASI HTTP 请求的 XCode 中遇到大量错误?

iOS NSURL 字符串

ios - 当AutoLayout在调试控制台中记录无法满足的约束时,如何使AutoLayout使我的应用程序崩溃?

ios - 动态选择变量

iOS Objective-C : How to be notified when the user taps on the spacebar?

objective-c - 通过后台点击和 Enter 连接两个发件人操作

iphone - 在Ipad中通过XML解析生成动态控件