iOS - Toolbar not showing - ios

Using the storyboard I created a new screen for a second View controller and added a Toolbar at the bottom. But when the view is shown, the toolbar doesn't appear. I'm using Segue to change views.
What could be wrong?

If you're using a Navigation Controller, make sure to tick "Shows Toolbar" and add the buttons there, not on a standalone toolbar.
In order to show only on some, you'll need 2 different views, one that will hide it and another that won't and add the following to the respective view's viewWillAppear:
self.navigationController.toolbarHidden = YES;
(Set to YES to hide, NO to show)
You can play around with the Simulated Metrics on the Storyboard so as to visually simulate the run-time effect by setting Bottom Bar to either None or Toolbar instead of inferred, as appropriated.
EDIT: Check this sample project I made.

Select the Navigation Controller in the storyboard. Under Bar Visibility, check "Shows Toolbar".

try this
self.navigationController.toolbarHidden=NO;

In the show the size inspector in the field autosizinf choose to bind to the top of the screen and remove the binding to the bottom of the screen.

Related

Navigation Item in XIB file is not visible

I'm in XCode 7.2.1 and I am trying to make a view that is reusable and should have some custom elements in the navigation bar.
If I would add a view to my storyboard, connect it via a segue to the navigation controller and make sure there is a "Navigation Item" in the view, I could see the navigation bar and edit my items in it.
If I manually add a Navigation Item to a XIB however I can't see anything. Even if I switch in the simulated metrics settings Top Bar to something else than Inferred or None.
I don't want to use the storyboard, if possible. Is there a descent way to make the navigation item visible and edit it?
Thanks in advance.
I don't think you link your View Controller correctly with Navigation Controller. When you link it, you should choose with root View Controller. If you link it correctly, you don't have to add NavigationItem manually.
By the way, you shouldn't do the customization for Navigation bar directly in xib. All you can do is only to set the Title, Prompt and Back Button text.
Do it in code! I think you won't have different styles for navigation bar in different views, right? That would be too silly.

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!

Hiding tab bar on one view in Xcode storyboard

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.

iOS: table view's title bar covered by navigation bar unexpectedly

I'm developing a simple UI for an iOS app.
what I've done is I developed it into a table view which has a navigation controller associated to it and had it laid out in Storyboard.
Everything seems working fine, except the navigation bar accidentally cover the view's title bar "Click to select item" as shown in the pictures below.
the first picture is when it first shows on the screen.
the second one illustrates when I drag the title bar off the covering navigation bar.
what do i do to get completely rid of this?
In Interface Builder, select your view controller and on the attributes inspector turn off Layout: Wants Full Screen. Then, your layout will automatically adjust its size to make room for the navigation bar.
Add this code in your viewDidLoad method
self.navigationController?.navigationBar.translucent = false
It works for me, since you've the same problem with me, I think it's work for you as well.
where u want hide navigation bar use this line
self.navigationController.hidden = YES;

Resources