title: How to deselect one segment when other is selected in UISegment iOS?
body: <p>This is what happening, 'Male' is primary so it remains selected and this happens when I select 'Female', please tell me why male is not deselecting itself?</p>
  
  <p><img src="https://i.stack.imgur.com/695Bw.png" alt=""></p>
  
  <p>this what I have done connected segment controller as <code>IBOutlet</code>: </p>
  
  <pre><code>@property (weak, nonatomic) IBOutlet UISegmentedControl *genderSelection;
  </code></pre>
  
  <p>then in <code>viewDidLoad</code>: 
  [</p>
  
  <pre><code>self.genderSelection addTarget:self action:@selector(MySegmentControlAction:) forControlEvents: UIControlEventValueChanged];
  
  - (void)MySegmentControlAction:(UISegmentedControl *)segment
  {
      if(segment.selectedSegmentIndex == 0)
      {
          // code for the first button
          NSLog(@"MALE");
      }
      else if(segment.selectedSegmentIndex == 1)
      {
          NSLog(@"Female");
      }
  </code></pre>
  
  <p>This is my attribute inspector:</p>
  
  <p><img src="https://i.stack.imgur.com/IZSkW.png" alt="enter image description here"></p>