Navigation Controller + segment Controlller : Unable to change the view
<p>I have a root view controller which has few buttons. On click of these button, I shown up a tab bar controller with each controller showing the table view controller. I have achieved this. So basically, for each table view controller I have a dedicated class. To go ahead, I replaced the tab bar controller, and added the segmented controller to the navigation title view.</p>

<p>The question is how can I set the view based on the selected index. I am able to set the navigation title to be segmented control but on select I am unable to set the view. </p>

<p>Below is what i have achieved so far.
Note: What matters is a running code, I would do that code optimization later on. I dont want to hidde views. <strong>I want to call different view controller class.</strong></p>

<p>RootViewController class (on click of the button, i call the first view controller. So that I can set the segment controller:</p>

<pre><code>-(IBAction) pushSegmentController: (id) sender 
{

    NSLog(@"My Location Button being clicked/touched") ;

    FirstViewController *firstViewController = [[FirstViewController alloc] init] ;
    [self.navigationController pushViewController:firstViewController animated:YES];

    // Releae the view controllers
    [firstViewController release];

}
</code></pre>

<hr>

<p>IN FirstViewController class:</p>

<pre><code>-(void)viewDidLoad {

    [super viewDidLoad];

    NSArray *viewControllers = [self segmentViewControllers];


    self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Table1", @Table2"]];

    self.navigationItem.titleView = segmentedControl ;

    [self.segmentedControl addTarget:self 
                              action:@selector(indexDidChangeForSegmentedControl:) 
                    forControlEvents:UIControlEventValueChanged];

    self.segmentedControl.selectedSegmentIndex =  0; }

-(void)indexDidChangeForSegmentedControl:(UISegmentedControl *)aSegmentedControl {

    NSUInteger index = aSegmentedControl.selectedSegmentIndex;

    if(index ==0) {
    UIViewController *table1Controller = [[AustraliaViewController alloc] initWithStyle:UITableViewStylePlain];
         **???? HOW SHOULD I SET THE VIEW OVER HERE... AS ITS A PART OF THE NAVIGATION CONTROLLER**
    }
    else { }
}
</code></pre>

<p>Note: I have tried using this option:</p>

<pre><code>[navigationController setViewControllers:theViewControllers animated:NO];
</code></pre>

<p>But this option doesnt give me the right result. How should I go ahead with the same as I want to call a view controller class and set its view based on the selected index.</p>

<p>Thanks in advance.</p>
