标签栏控制器应用程序中没有顶部导航栏 [英] No top navigation bar in a tab bar controller application

查看:96
本文介绍了标签栏控制器应用程序中没有顶部导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iphone编程方面很新,偶然发现了这个问题,我想这应该是非常基本的东西。

I'm pretty new in iphone programming and have stumbled upon this issue which I guess should be pretty basic stuff.

我正在使用从XCode IOS 5.1中的模板创建的标签栏应用程序。它工作正常并在故事板中创建了3个屏幕(标签栏控制器+ + 2个下降视图)但是当我尝试在这两个视图中添加顶部栏时出现问题...

I am using a tab bar application created from a template in XCode IOS 5.1. It works fine and creates 3 screens in the storyboard (tab bar controller + + 2 descended views) but when I try adding a top bar to these 2 views there is a problem...

我是通过在对象检查器的界面构建器中为标签栏控制器添加顶部导航栏来实现的。勾选此选项后,顶栏显示在我的故事板中,适用于所有3个屏幕(tabbarcontroller + 2个后视图),但在我运行项目后,顶部导航栏不再存在。

I do this by adding the top navigation bar in interface builder from object inspector for the tab bar controller. After ticking this option the top bar shows perfectly in my storyboard for all 3 screens (tabbarcontroller + 2 descended views) but after I run the project the top navigation bar is no longer there.

我在这里缺少什么?为什么没有顶栏?

What am I missing here? Why is there no top bar?

推荐答案

如果要在两个 ViewControllers上显示导航栏你的基于标签栏的应用程序,然后你可以这样做:

If you want to show a navigation bar on two ViewControllers of your tab bar based application, then you can do as follows:


  1. 删除viewcontroller1,然后从库中将 ViewController 拖到故事板中并选择它并转到Editor \ Embed In\Navigation Controller。

  1. Delete the viewcontroller1, then drag ViewController into storyboard from library and select it and go to Editor\Embed In\Navigation Controller.

UITabBarController 中,单击标签栏并右键单击,选择关系并将其拖动到导航控制器。 (意味着将 UINavigationController 添加为标签)。

From the UITabBarController, click on tabbar and right click, select relationship and drag it to the navigation controller. (means add the UINavigationController as a tab).

希望这有帮助!

这篇关于标签栏控制器应用程序中没有顶部导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆