I'm having a little bit of an issue. When I place the UIBarButtonItem on the tab bar controller it works perfectly, it displays as it should:
However, I can't put a button onto where the black square is. Does anyone know how I could do this non-programatically?
You should probably add a Navigation Item by dragging it from the Object Library to the place where you have marked in black and then try adding a Bar Button Item on the right. It should work
UINavigationBar wants only UIBarButtonItem. You can create one with custom View programmatically. Show here: https://stackoverflow.com/a/16058345/717193
Related
For some reason I'm adding left and right buttons to the navigation bar as its subview instead of using navigation item. When pushing a view controller, I'm setting its navigationItem.hidesBackButton to YES so that the ugly looking blue 'back' button will not show up. The problem I'm facing is that, after tapping my own back button, while the currently showing view controller being popped --- I mean during the animation of the 'pop', I can see a '...' in the navigation bar moving right along with the popped view controller. And, I DON'T want that '...' to appear for even 0.0000000001 second. What may I do now? Any hint would be appreciated.
Note:Problem solved with just comment. But posting this as answer so that It will help someone else having same issue.
I too had same problem with navigationBarButtonItem while adding custom barButtonItem to navigationBar in storyboard. If you are also using storyboard then just set navigationBar tint color as clear color in navigationController. By setting clear color, that weird default navigation back button will not appear anymore.
In swift, how do I add an icon to the navigation bar on the side instead of the middle?
I want to do what Slack does with their search icon by having it appear just next to the right menu icon, see picture here: https://static-s.aa-cdn.net/img/ios/618783545/1b2dca063c580767bf28c885e22c61bc
I DO NOT want the icon to be in the center of the navigation bar with the title view property, which is what most people do. How do I have the icon appear next to the right menu? Thanks.
Depending on the complexity of your requirements you have 2 options:
Create your custom navigation bar (is just a UIView subclass)
Create an image ad apply it as a background of the navigation bar
I have not tried this with Swift yet but this works on Objective-C. You can add multiple items to the right by passing an array of UIBarButtonItems to [self.navigationItem setRightBarButtonItems:]
you can subclass it and personalize your navigation bar, this tutorial is good for that:
http://www.ioscreator.com/tutorials/customizing-navigation-bar-ios8-swift
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
I am not a huge fan of using Interface Builder and for that reason I am new to it.
I am trying to add a UIToolbar to a navigation controller but because Apple documentation is always very clear, I don't have a clue.
I am converting an old project to use Storyboards.
This is what I have done.
I have added a storyboard to the project
I have added a navigation controller to it
Because I want this navigation controller to show a toolbar at the bottom, I have clicked on the navigation controller and turned the toolbar on (see pic).
after that, a white rectangle appeared at the bottom of the navigation controller on interface builder. I think this is a the UIToolBar or a placeholder. I have tried to drag a BarButtonItem to this "space" and Xcode allowed, showing it like this:
When I run the app, the toolbar shows as a white rectangle at the bottom but not the button.
The button shows like this on the hierarchy:
I suppose the button should be inside the Toolbar item, but Xcode forbids dragging the item there.
How do I make the button show?
The problem here is that your are trying to add an UIToolBar in a UINavigationController ...
Try in an UIViewController and that will work !
Edit:
Try this :
You just drag and drop the UINavigationItem on UINavigation RootViewController instead of UIToolbar.
It will allow you to put UIBarButtonItem on that UINavigationItem and works same like UIToolbar Button.
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!