views:

724

answers:

2

How to create an custom tabbar controller which has custom background image, custom icons, and custom labels and positioning but serves exactly the same purpose as UITabBarController. I badly seeking for an optimal solution for this.

When i learn the solution this will really help me to write a generic wrapper and save more time.

I have tried having UIViews and making it as footer and banner seperately, but it all consumes lots of memory. I want a simplistic approach which will make the development very optimal.

Please help me friends.

A: 

You could always try subclassing UITabBarController and do any desired custom behavior.

OscarMk
But subclassing the UiTabBarController has lots of problems and taking full control over the parent class's design is not fully possible, this is what i read, but not experienced. Maybe you are right, im not sure on this.
Futur
In the documentation for UITabBarController, Apple says "This class is not intended for subclassing."
Christopher Ashworth
+1  A: 
  • Create a view (in IB or in code) that will contain 2 subviews - one for tabs and one for content
  • Create view controller that will have references to both views
  • Design the tabs view as you want (BTW it may also be on top of the content view)
  • Drop few designed buttons on the tabs view
  • Each button will remove all the content view's subviews and add some view controller's view as a content view's only subview
Michael Kessler
This sounds good. but if i have to load a new xib, i will always have to load the tabs view again and again right? assuming each screen a nib, will this not affect the performance? please correct me if im wrong?
Futur
You won't have to load the main view each time. You will load only the content views and replace the displayed one with the new one. The tabs will always stay static and won't be loaded again, unless you will want to load some other "main view". All you will have to do is to switch the images in the tabs buttons - so that the button that was pressed will be the only one selected...
Michael Kessler
According to apple, they say having a separate view controller for page(view) is the best way to improve the performance of the system. I am bit confused here now, can you please help me getting his done?
Futur
I'm not saying that you don't need a separate view controller for each view. You will still have it. You will have a view controller for the main page and view controller for each content view. Once you touch a tab in the bottom you will initiate (if not initiated yet) a view controller of the target view (`initWithNibName:bundle:`) and replace the current subview of the content view to the new controller's view.
Michael Kessler
Excellent.. this should work.. let me check and revert back
Futur
hi.. thanks a lot for your kind support. you are great.I would like to have one more clarification : even if i keep loading new viewcontrollers from the main content view and swap views, imagine i have 10 screens(views) totally, each in separate view controllers(Xibs). when i want to load the 3rd view, when there is a click in the second view, i will still require a reference for the third view in the main content view right?so like the same, i will be having reference for all ten views in the main view itself, which will make the main content view heavy.Is this thought process is right?
Futur