Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

beachdog

macrumors member
Original poster
Aug 10, 2008
86
0
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

macrumors member
Jul 21, 2005
80
43
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

macrumors 6502
May 9, 2008
265
0
Bangalore
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

macrumors newbie
Sep 9, 2008
1
0
Please share the code online

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

macrumors member
Original poster
Aug 10, 2008
86
0
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:

Code:
- (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

macrumors newbie
Sep 30, 2008
13
0
Hyderabad,India
i also need same kind of application

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.