Hiding tab bar on one view in Xcode storyboard - ios

I have a Tab bar application where I would like to hide the tab bar for one of the views to exchange it with a toolbar. I am using Storyboard and by setting the Bottom Bar to None and dragging in a toolbar this looks the way I would want it on the storyboard.
But when I run it the Tab bar doesn't go away.

I had the same question but ended up finding my correct answer here
Essentially, you can hide the tab bar for certain view controller by checking the 'Hide bottom bar on push' check box (in the view controllers attributes inspector in the storyboard).
This might not answer all, and might not be compatible with =< iOS 5, etc, but it helped me and I hope it helps others who come here.
Thanks, and good luck!

It wont work because it only simulate the view when the tabbar is hidden. If you want to hide tabbar you have to do it programmatically.
See this answer Iphone: Is it possible to hide the TabBar?
and try to use hideTabbar method in viewWillAppear, and showTabbar in viewDidDisapear.

Related

xcode/storyboard: can't drag bar button to toolbar at top

I have a view controller that is the detail view of a table. When you click on the row of the table it takes you to the detail view. The detail view is embedded in a navigation controller such that there is a button at the upper left of the navigation bar that sends you back to the table. So far so good.
I now want to add an edit button to the right side of the navigation bar so that you can edit the detail view. My plan is this will add another view controller modally that lets you edit the details of the item. Standard stuff.
However, when I try to drag a bar button item from the list of objects to the navigation bar, it won't take. Instead, when I let go off the mouse button, it leaves the bar button on the tab bar controller at the bottom. (My navigation scheme includes different tabs and for each tab a table, detail view etc.)
Anyone run across this before and can suggest what I'm doing wrong or some sort of workaround to add the bar button item to the right side of the navigation screen. Do I have to add it in code?
Thanks for any suggestions.
I have got the same problem using Xcode6 and I noticed that UINavigationItem is added automatically for the first ViewController that you embed into NavigationController but for the subsequent ViewControllers, you will have to add it manually as follows:
In the Object library, find Navigation Item then drag it to your
2nd ViewController in the storyboard.
In the Object library, find
Bar Button Item then drag it the navigation item that you have created in the previous step.
Now you will have your Bar Buttons stuck to the top of your scene.
Update
The solution still works with XCode 7 but I wanted to add more descriptive photo. Just in case anyone is not really familiar with standard or technical names mentioned above. Notice the red arrows in the right, they refer to step 1, step 2 mentioned above. Also note the hierarchy of views on the left red rectangle.
Nasty trick:
Change your segue to push.
Set the content you need
Set back to show
Then the content will be editable and you have a non deprecated style for segue.
Your storyboard's view controller is likely missing a Navigation Item. You can drag one from the Object library, and drop it on your view controller.
You'll then be able to drag and drop bar button items onto the left or right side of the navigation bar.
i Solved it. drag in 'Navigation Item' to your detail view. than you can drag in the Bar Button Item.
The way that I fixed this issue was, instead of dragging a UINavigationController into the Storyboard and trying to add UIBarButtonItems to that, I dragged in a UITableViewController and then went to
Editor->Embed In->Navigation Controller
Which gave the same result as before except I could add UIBarButtonItems to both sides of the navigation bar with no issues.
Its actually xcode issue.
One trick which worked for me is to add the bar button in the VIEW FILE STRUCTURE ON THE LEFT.Instaed adding on the view directly.
Hope it helps you.:)
I think it is a bug. I had the same problem.I fixed this problem by disable the size classes, then enable it.
You can disable and enable the size classes in Interface builder doc.
I also had this problem, close and reopen the project worked for me.
I believe it's an XCode quirk. I had the same issue. I had to reset Xcode and shift the placement of things on the storyboard to finally get it to go. It's working now.
I think this is a bug of Xcode. In Xcode 8, change the segue in storyboard before the tab bar view controller to all its options (show detail, present...). Then back to show. Try to drag bar button items and modify tile. It works for me!
Did you try "cleaning" your project? I know that helps me sometimes (just go to "Product" > "Clean"). Or, alternatively, delete the navigation bar and try it again.
If you think it's a programming error, feel free to pass on your code. I'd be happy to help in any way I can. :)
You must reset xCode IDE . Close xCode and write the below codes at terminal...It will work.
rm -rf $HOME/Library/Application Support/Developer/Shared/Xcode
rm -rf $HOME/Library/Preferences/com.apple.dt.Xcode.*
rm -rf $HOME/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
rm -rf $HOME/Library/Developer/Xcode
Same issue. I had a Table View Controller inside a Navigation Controller and many ViewControllers following further down the chain. A 'Navigation Item' was being created automatically for the FIRST root view controller and I could add a 'Bar Button Item' to this without a problem. Via the Storyboard, drag and drop. But thats all. On the following Table View Controller and further view controllers, even though they were within the initial Navigation Controller (auto generated back button appeared), storyboard would never let me add a Bar Button Item.
Wael Showair's solution did not work for me. Bar Button Items wouldn't appear.
I solved it programmatically in the end (Swift 2.0):
var testButton = UIBarButtonItem(title: "Test Button", style .Plain, target: self, action: "testButtonMethod")
self.tabBarController?.navigationItem.rightBarButtonItem = testButton
No extra Navigation item or Bar Button Item needed.
I was too facing the same problem.I was able to fix this issue by selecting the root view controller option and then in simulated matrix changed the Top bar option to Opaque Navigation Bar and was able to add the item on top of navigation bar.Hope this answer will help someone.
I had the same issue in xcode 8. I had to simply close xcode and reopen the project and then I was able to add the bar button to the Root Controller without any issues.
For XCode 8
There are many answers here. I tried some of them but I couldn't make it.
So I found my solution, just select your ViewController, go Attributes Inspector section and change the Top Bar to Opaque Navigation Bar and Boom. You will see navigation bar on your storyboard. You can change the title or add some item. If you don't want to keep Opaque you can change style to Inferred.
In Xcode 10, I just changed the type of segue going to this new view controller to 'Push (deprecated)', added the navigation item as it was allowed after I made this switch. If you switch back to your originally desired segue type, the navigation item will remain.
Instead of drag the "Bar Button Item" to the "Navigation Controller", drag it to the "Detail View Controller".
As you embed the Detail view into the "Navigation View", "Navigation Item" will be added to the "Detail View Controller". If you drag the "Bar Button Item" to the right side of the Navigation Item, the item will be included under the "Right Bar Button Items"
like Mark Lyons said , I used the same solution.
used push segue first
added the bar item
return back to show segue
done
In Xcode 11, you can drag a button to the navigation bar to create your bar button.

bar button in Xcode always goes to bottom Xcode 6.3 beta

when i drag the bar button item onto the view controller they will not stay at the top of the view they will automatically go to the bottom under the table view. Does anyone know what is wrong?
You can fix this by moving the bar button item under the navigation item, inside document outline windows.
Before
After
That should fix the issue. I verified the issue in Xcode 6.3.2
If you navigated to this view-controller via a push segue, it does not have an instance of the navigation bar in storyboard.
You need to drag in a "Navigation Item" object, and then you can add your Bar Button Item on to this.
indy and timbrah's fixes didn't work for me... but the below did.
To fix this, select Navigation Item in the Object Library and drag it onto the Root View. Note, it replaces the current one. Then you can drag a Bar Button Item onto as you like. Hope this helps.
Actually, it seems as if the top bar isn't clearly designated as a navigation bar anymore. I had to select Root View Controller (first icon at the very top left of the screen) then chose the Show Attributes Inspector and at the Top Bar line item under Simulated Metrics chose Translucent Navigation Bar. That enabled it as a navigation bar and I was abled to drag a bar button item there. Weird!
I had same issue today with XCode 7. I have next stack: NC-(root)->VC1-(Show (e.g. Push))->VC2. After I've created VC2 there was no Navigation Item at all. To make it appear I changed segue type from Show (e.g. Push) to Deprecated Push and brought it back to Show (e.g. Push) and now I can use it correctly
You have to drag the Bar Button Item to one of the sides of the navigation controller's navigation bar. So, in your screenshot it would be all the way to the right or left of that bar that has "Root View Controller" in it.
From what I can tell this bug is still around in the 6.3 release. The only way I've been able to add items when this happens is to drag them under the navigation item in the left hand sidebar.
In my situation needed to select ViewControllerScene inside the document outline then forward attributes inspector then change Top Bar to Translucent Navigation Bar

UIBarButton placed in toolbar instead of UINavigationBar

I'm developing a (so far) simple iOS application using storyboards.
At one place in the storyboard, I have:
Navigation controller -> Table View (prototype content) -> Regular view
The "regular view" is accessed from a + (PLUS) button in the navigationbar in the table view. In the "regular view" I would like to have a save button in the NAVIGATION BAR. However, when I drag it from the object library to the "regular view" it appears in the TOOLBAR (at the bottom of the screen) instead of in the NAVIGATION BAR. I have not found a way to move it, or found any settings where I can change it. I'm not sure if there is something constraining me from putting a button there or if XCode just mess with me. (I'm new to iOS programming)
Notes:
In the "regular view", I have a back button and a title. According to the design guides I should be able to have one more button.
Thanks for any help!
If anyone faces this problem, I did the following:
I couldn't add a Bar button because there were no top bar in that view. First I tried to put a Navigation Bar in the view, but Xcode crashed. Then I tried to put a Navigation Item, which worked. After that I could place my bar button in the top bar.
What I don't understand is why I could put the Add (+) button in the previous view, since that doesn't have any navigation entry either, but I'm guessing it's since that view was the root view controller of a Navigation Controller. Someone else can maybe give a more detailed answer.
There isn't any solution for this so far. There are however some workarounds for this problem.
Check this pretty cool answer by #Shimanski:
https://stackoverflow.com/a/20419513/2082569
& also this by #ecotax:
https://stackoverflow.com/a/17019667/2082569

How to add buttons to navigation controller visible after segueing?

I have set up a view controller in Storyboard which is embedded in a navigation controller. In this nav controller I have checked Shows Navigation Bar and Shows Toolbar and enabled a navigation bar and toolbar in Top Bar and Bottom Bar respectively in Simulated Metrics. I then "Show e.g. Push" segue from the view controller to another view controller. On both view controllers I've set up Simulated Metrics the same way, so both the navigation bar and toolbar are visible on all three controllers.
The problem is, I can add bar button items to the first view controller to both the navigation bar and the toolbar, but I cannot add a bar button item to the navigation bar on the second view controller. When I drop a button on the navigation bar, it's added to the toolbar instead. And I cannot double click the nav bar to add a title. In the outline I see there is no navigation item on the second view controller, but it is there in the first view controller.
I can probably add buttons to the navigation bar programmatically, but I want to do this visually in Storyboard. My question is, what is wrong with this setup, or is this a bug with Xcode?
For XCode 6, the UINavigationItem for the 2nd view controller onwards is not added automatically on the View Controller Object inside the storyboard. You will have to drag the UINavigationItem onto the Navigation Bar for that view Controller Object before adding UIBarButtonItem on top of it.
I am not sure why it is designed that way. I only discovered about this a few weeks ago.
If you have a ton of view controllers and very little custom auto-layout stuff in place, you can disable size classes, then re-enable it will add all missing nav bars across your storyboard.
Obviously not recommended if you have a ton of custom auto layout stuff linked up.
If you have just a single UIViewController that's missing a nav bar, just drop a UINavigationItem onto it.
If you're using Xcode 7 beta 4/5, try restarting Xcode it solved the issue for me
I just bumped into this issue and it seems to be affected by the segue that shows the view controller.
If "Kind" setting in segue is "Show (e.g. Push)", it's not possible to drag the item to top right corner. However, if you explicitly change "Kind" setting to "Push", this can be done.
Edit: actually I just noticed that "Push" is deprecated. Not sure what Apple is thinking here. However, you can just change it back to "Show" after adding the button and it seems to work :D
For second view controller in hierarchy, you can setup title in attributes, without adding "navigation item"
I think it is a bug. I had the same problem.I fixed this problem by disable the size classes, then enable it.
You can disable and enable the size classes in Interface builder doc.
It's very simple. You just need to use navigaitonItem first as the holder of the buttons and then you can add barButtonItems on top of that.

iOS. Navigation controller toolbar - customize example

I'm newbie with Xcode, I'm learning it and trying to make my app.
Now I would like to put Navigation Bar func at the bottom of the screen with some customize.
I turn on "Shows Toolbar" at Navigation Controller and put my button there, but I cannot customize it.
Everything that I found about customizing Navigation Bar at the top of the screen or about customizing TabBar when people are talking about bottom of the screen.
Please, can you give me a code examples to build something like this at the bottom of the screen:
https://dl.dropboxusercontent.com/u/1338320/nav.png
Thanks in advance!
I'm not sure what you are trying to customize (button or bar) but when there is a bar at the bottom of the screen that is not a tab bar it is a tool bar not a navigation bar. The two are related but they each have their own class. Tool bars use UIToolBar not UINavigationBar. The tool bar is independent of the navigation controller and the two work together well. For any views that don't want a tool bar just set it to hidden in -viewDidAppear: (you will need to un hide it in views that use it).
dimimpou is right. You can accomplish this by using a UITabBarViewController and one UIBarButtonItem for "ADD ONE" and "MY STATS".
If you get lost in references(I sometimes get lost too), I may provide a simple example.
Note that if the interface provided by UIKit doesn't meet your need you can:
Use category over UITabBar or UITabBarItem.
If 1. doesn't work sadly you'll have create your own view controller which is simulate UITabBarViewController(requires some time, but it's worth)
Edit:
You can use a UINavigationController inside a UITabBarViewController.
You can easily do this. The way I understand it, you want this "Toolbar" to show from a button in the navigation bar. Just put a tab bar with what you need and make it show when the user presses the button on the navigation bar. on this buttons action put this code: self.tabBar.hidden = NO; and on the storyboard uncheck the bar visibility option. Hope it helps!

Resources