PDA

View Full Version : need example of tabbar with navbar




beachdog
Aug 27, 2008, 10:37 PM
I have worked my way through building an app with a navbar, and now have a pretty good understanding of that. And I created an application template for a tabbar application and kind of see how that works. But I need to build an app that has both a tab bar as well as nav bars. Is there a sample app that falls into that UI design which I could look at ?



belsokar
Aug 28, 2008, 12:42 AM
I have worked my way through building an app with a navbar, and now have a pretty good understanding of that. And I created an application template for a tabbar application and kind of see how that works. But I need to build an app that has both a tab bar as well as nav bars. Is there a sample app that falls into that UI design which I could look at ?

Create the TabBarView Controller in your main application delegate.

Now Create your NavBarViewController. You need to add your NavBarViewController to the ViewControllers property of the TabBarViewController.

You then add your TabBarViewController to your main window.

PM me if you want to see some sample code.

sujithkrishnan
Aug 28, 2008, 01:18 AM
Create the TabBarView Controller in your main application delegate.

Now Create your NavBarViewController. You need to add your NavBarViewController to the ViewControllers property of the TabBarViewController.

You then add your TabBarViewController to your main window.

PM me if you want to see some sample code.

Hi...

Adding to the question above can u please suggest me a method to redraw the tabBar at runtime ???

means... can we change the items of tabBar as per user choice...

I created the tabBar with navBar as you suggested above...

Little bit of code is also much helpful....

dwsouth2
Sep 9, 2008, 03:45 PM
Hi,
I am having a problem with this also. Could you please post your example code or contact me. The light at the end of the tunnel is evading me.
Thanks
Tony
Create the TabBarView Controller in your main application delegate.

Now Create your NavBarViewController. You need to add your NavBarViewController to the ViewControllers property of the TabBarViewController.

You then add your TabBarViewController to your main window.

PM me if you want to see some sample code.

beachdog
Sep 9, 2008, 11:58 PM
I did it mostly thru interface builder, which makes it difficult to show code, but here are the steps I did:

First, I started by creating a basic tab-bar project, without navigation controllers. This created my main nib file, with the tabs along the bottom of my main window and the views associated with each above.

Then, for the particular tabs where I wanted to show the associated view under a nav bar, I selected that tab button in Interface Builder, and in the inspector I then changed the Class Identity of the associated view for that tab from UIViewController to UINavigationController. That seemed to be the main trick.

I then selected the view itself (the view which appears under the nav controller, which in my case is a UITableView) and I changed its Class Identity from UITableViewController to my custom class which inherited from UITableViewController. I also specified that that view controller should be associated with a different nib file. That nib file simply had the table view that I wanted to show beneath the nav bar, with File's Owner being my custom UITableViewController-derived class.

The upshot is that when the user clicks that tab bar it creates a navigation controller. The navigation controller in turn then creates an instance of my custom UITableViewController-derived class and loads the second nib file containing that view. My custom class then accesses the navigation bar by means of code like this:


- (void)viewDidLoad {
[super viewDidLoad];

/* I wanted a segmented control to appear in the nav bar */
UISegmentedControl* ctl = [[UISegmentedControl alloc] initWithItems:[NSArray
arrayWithObjects:NSLocalizedString(@"all",@""),NSLocalizedString(@"restaurants",@""),NSLocalizedString(@"favorites",@""),nil]];
ctl.segmentedControlStyle = UISegmentedControlStyleBar;
[ctl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
ctl.selectedSegmentIndex = 0;
self.navigationItem.titleView = ctl ;

/* set the nav bar title */
self.title = NSLocalizedString(@"food_list","");
}

siva.d
Nov 3, 2008, 12:16 AM
Hi,

I need same kind of application.

I have some doubts, how u connected in nib files.

Can you give sample code of the application you created.

By seeing those nib files, i will try to understand.

Thanks
shiva

matthew858
Nov 3, 2008, 02:56 AM
I would also love a .xcodeproj file that somebody is willing to share. I am not quite sure how to do this, as my app keeps crashing.

siva.d
Nov 11, 2008, 05:52 AM
Hi,

i got a solution.

if you want that source code.

send your mail ID to this mail ID sambasivarao4u@gmail.com