title: Use segmented Control to switch between 2 views
body: <p>I make an iphone application that use a segmented Control to switch between 2 viewControllers that display different informations. So, I defined in the first view Controller a segmented Control that I linked in IB to a Segmented Control that I place on the corresponding view.</p>
  
  <pre><code>@interface FirstViewController : UIViewController{
  
  //NSArray                * viewControllers;
  //UINavigationController * navigationController;
  IBOutlet UISegmentedControl *segment; //-&gt;segment linked in the nib of FirstViewController
  
  }
  </code></pre>
  
  <p>The action related to the segmented control is the following:</p>
  
  <pre><code>-(IBAction)valuechanged:(id)sender{
  
  NSInteger index = [(UISegmentedControl *)sender selectedSegmentIndex];
  
  UIViewController *parking=[[ParkingViewController alloc] 
  initWithNibName:@"ParkingViewController" bundle:nil] ;
  
  viewControllers= [NSArray arrayWithObjects:self,parking,nil];
  
  
  if(index==1){
      UIViewController * incomingViewController = [viewControllers objectAtIndex:index];
      [self presentModalViewController:incomingViewController animated:YES];
              }   
  }
  </code></pre>
  
  <p>In this Action, I define what to do once user click on segmented control.Here, it's loading a new viewController named ParkingViewController. The problem is that once the new ParkingViewController is loaded the segmentedControl disappear and so I can't come back to the firstViewController.</p>
  
  <p>I don't know how to do to keep the segmentedControl for both views?</p>
  
  <p>Thank u all</p>
  
  <p>Quentin</p>