首页 文章

导航栏隐藏

提问于
浏览
0

我的导航栏出现问题 . 它没有出现在它应该的位置,并且在Xcode界面构建器中的“模拟度量”下,“顶栏”属性设置为“黑色导航栏” . 在我的代码中,我也将hidden属性设置为false,因此这不应该是问题 .

我的底部确实有一个 UITabBar ,但在"Simulated Metrics"类别中也是如此 .

见:http://postimage.org/image/jv4lremwl/full/

2 回答

  • 1

    "Simulated Metrics is as it's name indicates: a "模拟表示“未与您在代码中(或在XCode界面构建器中)创建(或未创建)的任何对象连接 . 如果您将模拟的 NavigationBar 设置为黑色或模拟指标中的任何颜色,对您的实际项目没有任何意义,因为它只是一个视觉参考,如果您实际实现它将如何显示它 .

    如果你想拥有"real"导航顶部栏,你必须实现 UINavigationController ,或手动添加 UINavigationBar (通过代码或直观) .

  • 2

    集成Tab栏Contrller和导航栏控制器的最简单方法是使用代码创建它们 . (这是我大多使用的)

    //Creating the navigation bar
    //rVC is some root view controller you have on your code
    
    UINavigationController *nav1 = [[UINavigationController alloc] init];
        [nav1 pushViewController:rVC animated:YES];
        nav1.navigationBar.barStyle = UIBarStyleBlack;
    [rVC release];
    
    //Creating the tab bar custom image and title
    UITabBarItem *tab1 = [[UITabBarItem alloc] initWithTitle:@"Nav1" image:[UIImage imageNamed:@"nav1Image.png"] tag:1];
        [nav1 setTabBarItem:tab1];
    
    //making the navigation bar visible in the inside tab bar
    UITabBarController *tabController = [[UITabBarController alloc] init];
    tabController.viewControllers = [NSArray arrayWithObjects:nav1, nil];
    

    希望它对你有所帮助 . 干杯

相关问题