Chris
Chris

Reputation: 242

Custom iPhone App Tab Bar

Alright, this seems simple enough but I haven't found much documentation or posts regarding this. Basically, I want to have a completely custom tab bar at the bottom of my app. Being new to iPhone dev I thought I could do the following:

  1. Place custom images on bottom of screen to act as tab buttons.
  2. Create a UIView (lets call it "ContentView") to fill the rest of the screen that will display the appropriate tab's NIB. This "ContentView" is inside the main UIView for the NIB.
  3. Hook up image "press" actions to the controller managing all this.

I'm not sure how I would go about loading the appropriate NIB into the "ContentView" with this method though. From the "Touch Up" action method in the controller can I dynamically load a NIB into that "ContentView" UIView?

Something about this whole thing makes me uneasy.
Is there a better way?

Upvotes: 1

Views: 1553

Answers (2)

David
David

Reputation: 14404

To solve your problem I would create a nib with a UIView and its associated content in it. Connect the nib to a UIViewController. This will be the content of each tab. Create as many of these UIView-UIViewController combination as needed.

When the user touches a tab, create and load the UIViewController from the nib using

– initWithNibName:bundle:

Add the UIView in the nib to the main content view as a subview. Use

– addSubview:

As the user presses other tabs load the other nibs into memory and add their UIView into the main content view as a subview.

If a view is already in memory you can show and hide subviews with the following methods.

– bringSubviewToFront:
– sendSubviewToBack:

I think that would work.

Upvotes: 3

Ishu
Ishu

Reputation: 12787

You can solve this by,

either make different views with same tab bar image and custom button(load view on IBAction for button click:toucp up inside) or you can make different views for the same view(so you can hide views and show only one view at a time accordingly).

and you can load view (if you app is view based then add other views on window otherwise for navigation based app you need to pushViewController of navigation controller.

This is a tricky task but you need to handle this.

Upvotes: 0

Related Questions