How do I switch UISegmentedControl programmatically?
The selectedSegmentIndex property identifies the selected segment of a UISegmentedControl. Set this property to the any valid segment index, or UISegmentedControlNoSegment (-1) to turn off the current selection.
// select the first segmentsegmented.selectedSegmentIndex = 0;// turn off the current selectionsegmented.selectedSegmentIndex = UISegmentedControlNoSegment;
Alternatively, after you have changed the selectedSegmentIndex call 'sendActionsForControlEvents:' for example
segmentedControl.selectedSegmentIndex = 0[segmentedControl sendActionsForControlEvents:UIControlEventValueChanged];
In Swift:
segmentedControl.selectedSegmentIndex = 1
Swift 2:
segmentedControl.sendActionsForControlEvents(UIControlEvents.ValueChanged)
Swift 3:
segmentedControl.sendActions(for: UIControlEvents.valueChanged)