LolaRun
LolaRun

Reputation: 5666

what's the difference between tab bar controller and tab bar?

hi I'm new to objective-c

i need to create a view, that has four buttons at the bottom, and a view above them that changes according to which button you press.

now i've been reading a bit of tutorials, and i still have difficulties understanding the different nib files. But i'm wondering.

i have 'tab bar controllers' in the controllers sections in the library and i have 'tab bar' in the 'windows views and bars' section. now according to what i've read, and understood...

i have to use tab bar controller and add it to the 'Mainwindow.xib' and implement and link the stuff.

But can't i just add a tab bar in my 'appnameViewController.xib', and manage the tabbar items' click to change views. without relying on the tb controller??

Upvotes: 2

Views: 3902

Answers (3)

Robert Höglund
Robert Höglund

Reputation: 10070

If you want tab bar functionality you really should use UITabBarController. While it is possible to repsond to the the taps on the tap bar and switching views by yourself it is not recommended. Some reasons why:

  • You would just duplicate code that UITabBarController already does.

  • UITabBarController will handle things like unloading views not on screen when a memory warning is received.

  • If you end up changing the amount of tabs in your application it would still just work with a UITabBarController.

There are probably many more better reasons but since an iOS device have limited memory the memory aspect alone would make it a no brainer.

Upvotes: 3

Meltemi
Meltemi

Reputation: 38349

I think you are confusing the tab bar view with it's view controller (UITabBarController).

Apple's documentation explains it well: http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html

Upvotes: 0

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

You need to familiarize yourself with the Model-View-Controller design pattern, which Cocoa follows religiously. Controllers deal with the application-specific logic the user interface (the views) provides.

For example, a button is a view but a controller handles the button's click (and setting its enabled/disabled state, etc.) depending on application logic.

Upvotes: 1

Related Questions