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

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.

Related

How to implement a navigation bar for popup dialog in IOS?

I have a small UI dialog box (UIView) I will be showing at one point (in fact a pop-up over a mapkit map. In this dialog I wish to have a navigation bar at the top that let's a user step through different data item (so a Back/Next set of buttons in the navigation bar).
Question: Should I look to try to utilise an IOS UINavigationBar and/or UINavigationController etc to build this little pop up? Or should I just build this in XCode by hand (e.g. draw a navigation bar and put normal buttons in myself). [Also if you can let me know why re your response so I can learn].
Background: At the moment I have an XIB dialog box in XCode which I have size set to "freeform", and then I instantiate this using:
calloutView = NSBundle.mainBundle().loadNibNamed("GCCallout", owner: self, options: nil).first as! GCCallout
I would say, it depends on your dialog box requirement
You mentioned, that you need back and next button in navigation bar, as I understand, you simply want to manipulate the data in dialog box or do some operation using it.
If you would want series of view controllers inside dialog box, pushing after each other, then only navigation controller would be good to use in your dialog box
Otherwise, using it simply for navigation bar would be overkill.
UINavigationControlker is a Container Controller and is optimized for keeping view controllers in stack and pop them up.
I suggest, go for custom UIView from xib or if dialog box have much code to handle than, implement your dialog box in view controller, and add it as child view controller.

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.

What approach should i use when making tab bar application

I'm started to work at new place as iOS programmer. I joined existing project and got an assignment that i don't really know how to approach.
So my problem is this: when you press a button, next window has to have a tab bar with four icons, this means four different navigation stacks. Its not that hard to make, but in main screen i have more then four icons, and if i press any one of them next window always has to have a tab bar with four static icons, like shortcuts or something.
So what should I do? Does anyone had the same situation? I want to start with a good advice to save trouble later on.
You should probably rethink the app design. Tapping an item on the tab bar shouldn't result in a different number of tab bar items, as it leads to an unstable and unpredictable UI.
While not the most efficient in terms of visible content, you could introduce a segmented control (or a similar custom view) on top right under the navigation bar (if there is one), as seen in the Facebook app (though here it is used to perform actions, not changing views).
Your root view controller should be embedded in a navigation controller. Then push a view controller which contains any number of tab bar items not TabBarController. Then you can present each view controller either push or custom.

Make More button in tabbed bar application slide out in iOS

This is a simple question. So I have a tabbed bar application with a More... tab button. I was wondering if it's possible to make the More... button be a slide out menu button? I found tutorials on how to do it on a regular app design but things get a little more complicated when it comes to the tabbed bar application.
The thing is that you don't own the More button in the tab bar of a UITabBarController, so you can't control what happens. (You can access the navigation controller that appears when the More button is tapped, but it's still going to be just another view controller whose view is displayed above the tab bar.) If you want to write a new interface you'll have to write a whole new interface, i.e. don't use the built-in UITabBarController. That's no big deal; it isn't doing anything you can't manage to do yourself.

Tabbar not showing in ios application

i am making one iOS tabbar application in that i have put 4 different tabs and whenever i click on 1 st tab and load another view after clicking of the first tab. After that when i press back button then tabbar is not displaying .So that i want hint that how can i show that
back the tabbar when we move from one tab from another and yes how i can use consistent the tabbar in whole application can you just guys help me on this i am new to iOS development.
here i am put the screen shot ...
here first screen is this one..
when i tap the video button that are first in the view then another window open
which are as under and see the tabbar is not there...
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Looking at your screen snapshots, do I correctly assume you're attempting to transition to the "Videos" scene by touching the big "Videos" button in the center of the "Home" scene (rather than touching the tab bar button at the bottom of the screen, which I assume works fine)? If that's the case, you need to have your button tell the view controller's tab bar controller that you want to change the index of the tab bar, and it takes care of it for you. You cannot do the transition using a segue (or at least not without a custom segue, which is even more complicated than the procedure I outline below). If you're changing the view some other way (e.g. using a standard segue or using presentViewController, pushViewController programmatically, etc.), your tab bar can disappear on you.
You later said:
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Yes, that's true. You cannot use a segue from one of your big buttons to one of the tabs in your tab bar. (Or technically, if you wanted to use a segue, it would be a custom segue which would do something very much like my below code, though perhaps a tad more complicated.) So, rather than using a segue for your big button, you need to write an IBAction (connected to the big Videos button on the Home scene), that tells the tab bar to change its selection:
- (IBAction)clickedVideosButton:(id)sender
{
[self.tabBarController setSelectedIndex:1];
}
A couple of comments:
My answer was predicated on the assumption that your tab bar works as expected when you tap on the buttons of the tab bar, itself. If you tap the buttons at the bottom of the screen, do you transition to your other views correctly and preserve the tab bar? If so, my answer above should solve your issues in getting the big buttons to work. If not, though, then the problem rests elsewhere and you need to show us your code that might account for that (either you're something non-standard in the UITabBarControllerDelegate methods, or your viewDidLoad of the view is doing something nonstandard).
If I understand your user interface design right, you have the tab bar at the bottom as well as the big buttons in the middle, which presumably do the same thing. That is, no offense, a curious user interface design (duplicative buttons, requiring extra tap on a button, etc.). You might want to choose to either use either big buttons (in which you can retire the tab bar, eliminate the IBAction code I've provided above, and just use a nice simple navigation controller and push segues, for example), or just use the tab bar (and lose the home screen, lose the big buttons, etc.).
You also made reference to "press back button", and I don't see any "back" button on any of your screen snapshots. Do I infer that you have a navigation controller and you're doing a pushViewController or push segue somewhere? If you're doing something with back buttons, you might need to clarify your question further.

Resources