How do I switch UISegmentedControl
programmatically ?
EDIT: as Yogesh Nikam Patil made me notice, UIControlEvents has been renamed from UIControlEvents to UIControl.Event. I've updated my code accordingly.
@arcady bob answer was the one that did the trick for me.
I just post an updated version for SWIFT 5:
yourSegmentedControl.selectedSegmentIndex = 0
yourSegmentedControl.sendActions(for: UIControl.Event.valueChanged)
If you use just the first line, the segmented will react accordingly graphically, but your IBAction associated with the segmented control won't be called. In a few words: the second line is like tapping on the segmented control. This is what I needed and what I was missing.