Disable other bar button items when one is being touched: Navigation bar - ios

I have a navigation controller, in its navigation bar i've 2 right bar button items, I want to disable one right bar button when the other is being clicked/tapped. How to achieve this??
Thanks in advance.

Unfortunately UIBarButtonItems only have one callback and that's the equivalent of UIButton's UIControlEventTouchUpInside.
If you want to do something when the user presses and releases a button (disable/re-enable other buttons) you might have to get your hands dirty with some custom UIBarButtonItems that have UIButton's as customView and do some careful event handling to know when to enable/disable each.
On a personal note: pressing more than one bar button at the same time is not very common and shouldn't present a problem, whatever implementation you may have.

Related

Add logo to left side of Back button in navigation bar

I am trying to add a logo to the very left side of my navigation bar. I still want to display the Back button and the title of the page, but the logo must be fixed to the left side before the Back button.
I tried adding the logo as a Bar Button Item, but this removes the Back button.
Is there any way to do this? Thanks in advance!
If you add a UIBarButtonItem as the leftBarButtonItem then you can also set the property
self.navigationItem.leftItemsSupplementBackButton = true
This will allow you to have two buttons without disrupting the back button. However it won't be on the far left, that space is reserved for the back button. If you want to go against Apple's design guidelines and the logo is more important the standard iOS navigation, you'll need to do something custom.
You could use the leftBarButtonItems property on UINavigationItem to set multiple items in your own order. One of those could be a logo and another a custom back button that you set to call navigationController.popViewControllerAnimated(true)

An UITabBar like Tweetbot3

I would like to know if someone have an idea about how Tapbots made Tweetbot3 TabBar?
In my app, there will be many TabItems, and I don't want the "More" Tab (by default), but I'm very interested to have a similar system to Tweetbot, with a "picker" which opens on long press gesture on a TabBarItem.
But, I'm hesitating on the method. It's better to apply a customized UITabBar class, or to totally "deconstruct" the UITabBarController (to use a UIViewController and a custom "tabbar")?
Having created many custom tab bars, I'd start by subclassing UITabBar and UITabBarController. I wouldn't expect any roadblocks with this approach.
You may want to move the default buttons around and then add some custom buttons. Send a message back to the tab bar controller and let it display the popup choices view.

Should I use a tab bar or button at the bottom of my ViewController?

I'm just learning iOS, and I want to create an App which will have a few buttons at the bottom of the screen.
What I'm a bit unsure about is, I know you can use a tab bar down there, but is that what you should always use when you want a button at the bottom of the screen? or there's no need to use a tab bar, and you can just put a normal button down there?
According to apple's documentation, UITabBar is a control used for displaying views.
A tab bar is a control, usually appearing across the bottom of the screen in the context of a tab bar controller, for giving the user one-tap, modal access to a set of views in an app.
If your goal with this "button" is to display other views, then you should use UITabBar component.
But if you are just searching for a "usual button", then you should use UIButton component.
A tab bar is expected to allow the user to switch between, you know, tabs; the same bar appears at the bottom of each page, and it allows you to switch between them. If that describes what you are trying to accomplish, then it would be appropriate. If your button is meant for some different purpose, then a tab bar might be misleading.
A tab bar (class UITabBar) is usually part of a tab bar controller (class UITabBarController). A button (UIButton is simply a way to respond to a tap or other actions within the button.
You want to use a tab bar and tab bar controller when you need to switch between different views and view controllers in your application. For example the Music app on your iPhone has a tab bar controller that switches between Artist, Playlist, Album, etc. These are different screens, or screens that look the same but show your music organized in a different way.
If all you want is to respond to a button, for example to print out to the console or show a message to the user that says "Hey, you've tapped the button", then a UIButton is what you need.
Also, a UIButton can have many actions, Touch Up Inside is probably the one you are looking for. This one will ensure the button has an action called if the user began a tap on the button, and let go of their finger while still on top of the button.
To summarize things:
Use a UIButton if you simply want to respond to an action, and the most common action you will connect to the button is Touch Up Inside.
Use a UITabBarController to have a way to switch between different views and view controllers.

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!

iOS possible for draggable hide button on UITabbar?

Is it possible to add a custom button ontop of a tabbar which can be used to hide and show the tabbar?
I can hide the tabbar but i want to be able to do it from the tabbar itself (button on it)
Any ideas?
Just for completeness (I know you have found this elsewhere), but you can use my "PeekabooTabBarController" for this:
https://github.com/a1phanumeric/PeekabooTabBarController
It allows you to show and hide a UITabBarController, and even allows more buttons which scroll horizontally.

Resources