No top navigation bar in a tab bar controller application

两盒软妹~` 提交于 2020-01-01 10:28:21

问题


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

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...

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?


回答1:


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

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

  2. 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).

Hope this helps!




回答2:


follow as Nuzhat Zari to show navigation bar on viewcontrollers of your tabBar based application




回答3:


 self.tabBar.frame =CGRectMake(0,0,self.view.frame.size.width,50);

This will make Tab Bar to appear at the top of controller.



来源:https://stackoverflow.com/questions/11083521/no-top-navigation-bar-in-a-tab-bar-controller-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!