Display TableViews corresponding to segmentedControl in a single tableview without pushing a new view
- by user1727927
I have a tableViewController where I have used the Interface Builder to insert a Segmented Controller having two segments. Since by default, first segment is always selected, I am not facing any problem in displaying the tableview corresponding to first segment. However, when I click on the second segment, I want to display another tableView.
Here goes the problem.
I am calling newTableViewController class on clicking the second segment. Hence, this view is getting pushed instead. Please suggest me a method to have these two tableViews in the main tableView upon clicking the segments.
I have used switch case for switching between the segments.
Here's the relevant part of the code:
This method is in the FirstTableViewController since first segment is by default selected.
-(IBAction) segmentedControlChanged
{
switch(segmentedControl.selectedSegmnentIndex)
{
case 0:
//default first index selected.
[tableView setHidden:NO];
break;
case 1:
NewViewController *controller=[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
self.navigationController pushViewController:controller animated:YES];
[controller release];
break;
default:
break;
}
}