I am new to ios programming working on my first app. I have a tab bar controller with two tabs A and B. Both tabs are connected to table view controller with some data being shown. I want to add a bar button item on the top left "navigation" bar of the table. This would be a slide bar menu navigation item as shown in figure below
However, even though in my storyboard the menu bar button item shows up (as shown in the pic), when I run the program, the table corresponding to tab "A" that gets displayed does not show the menu item.
UPDATE: Solution (see the marked answer and comments) -Basically, you need to embed the table view controller in navigation view controller, set "Top bar" to "Navigation Bar" and then you can add a bar button item.
UPDATE 2 - Setting the top bar to "Navigation Bar" in attributes of the table view controller is optional.
Instead of inserting the bar button in the tab view controller insert it in view controller "A."
Related
I am using SWRevealViewController for side menu.
and also I have a tabbar controller as main view in my app.
In my menu I have "MenuItem" (which presents MenuItemViewController) and the tab bar items are "TabItem1" and "TabItem2".
Here is what I need:
Show the tab bar in "MenuItemViewController".
To have back button(bar button) that goes back to the TabItem1ViewController.
I do not want to have a new item for "MenuItem" in my tabbar.
What I Have
What I Need
BTW, the top left view controller is the side menu.
I have something that i think will match your requirement, or maybe you'll get an idea from this.
What's happening here is a tab bar with any number of view is embedded inside a navigation bar. and the menu screen is the rear view of swrevealView and navigation bar is the front view. Ask if you have any doubt.
I have a UITabBarController with 4 tabs, suppose A,B,C and D. I have a table view in page A. On clicking on any of the rows, E page opens.
The problem is that on creating show segue from view controller A to E, the tab bar appears below in E in storyboard, whereas during runtime no tab bar is visible on E. Please could anyone help me out in this.
EDIT :
I can add tab bar item to tab bar of subview as below:
This is the view hierarchy :
Note : I want to the tab bar of the main A-D tabs in all sub pages of A-D
I want to show you two images in different conditions. Maybe it's not a answer but will help you in some manner.
!) I have tab bar controller connected with navigation controller. That Tab bar has two items. "Top Rated" view has a button that connected to other view controller. Check right hand side attribute section for this bottom bar is none.
2)Same condition for second image but this time I changed the bottom bar option of this view controller(check attribute section). Now the view controller has tab bar item.
But this will not show in run time because this is not connected with tab bar controller. One more thing you can easily put tab bar item on new view controller that are not connected with navigation and tab bar controller, but when you run it will not there.
Updated:
This will help you. Try to set navigation inside of tab bar controller. Give tab bar item to navigation controller. Like:
Output is:
When button clicked:
In that manner you can tab bar in all views.
Update 2:
Here I have Navigation then Home view then the above process with tab bar controller and its working fine.
Updated Output:
When button clicked:
My App has two pages, so in interface builder I have three controllers:
A NavigationController
segues via RootViewController to TableViewController1
segues via push to TableViewController2
I easily added a Bar Button to the right side of the navigation bar of TableViewController1 by dragging it from the tools.
Tried to do the same thing in TableViewController2 and it won't drop the bar button.
I have the "Shows Navigation Bar" attribute checked on the Navigation Controller and I can see a space for the navigation bar on TableViewController2, but I don't see the same "Navigation Item" in the component hierarchy that I see for TableViewController1.
If I drag a bar button to the controller itself it puts a new NavigationItem icon on the controller (between First Responder and Exit) and that looks promising, but it doesn't show when I run the app.
For this TableViewController2, you have to explicitly add a navigation item into the xib and then you can add bar button items on it.
It will look like this in xib , you can set title and button.
I am new in iOS. I use Seven Tab bar item in my tab bar controller story board and when run app then it shows more buttons when I click on it it is also show edit button. I do not want that edit button. How can this be done?
This is my code:
[[[tabBarController moreNavigationController] visibleViewController] setTitle:#""];
But it does not work.
You had to say that none of your view controllers is customizable. Then the edit button disappears. Please look up the docs.
tabBarController.customizableViewControllers = #[];
Docs: "This property controls which items in the tab bar can be rearranged by the user. When the user taps the More item on the tab bar view, a custom interface appears displaying any items that did not fit on the main tab bar. This interface also contains an Edit button that allows the user to rearrange the items. Only the items whose associated view controllers are in this array can be rearranged from this interface. If the array is empty or the value of this property is nil, the tab bar does not allow any items to be rearranged."
On Swift: You can also have those items you want to be editable in the array:
tabBarController.customizableViewControllers = []
Ensure that if you have a navigation controller for the tabbar controller that it is not translucent because the more navigation bar will be behind the main navigation bar. This sometimes shows an empty space above the more tableview.
You can completely hide the more navigation controller if you do not need it, since tapping the more tab pops the top view controller.
tabBarController.moreNavigationController.navigationBar.isHidden = true
In my iOS application I have a tab bar view with three views. I would like each of those views to have a "navigation" bar at the top. I would like the navigation bar to have a left bar button item which has the same functionality across all three views, and then a right bar button item which is unique to each view. How should I build this?
In each tab, put a UINavigationController. That's a separate one for each tab.
Set the root view controller of each navigation controller to a view controller that manages the content view you want to display.
You can set the left button item of each of the three navigation controllers to the same thing, and set the right button item to something different.