UISegmentedControl deselect (make none of the segments selected)

dusker picture dusker · Feb 5, 2010 · Viewed 30.3k times · Source

in fact the title contains my question. I have a UISegmentedControl, and need to deselect currently selected tab. I tried:

[menu setSelectedSegmentIndex:-1];

menu being the UBOutlet for uisegmentedcontrol but this gives me exception. anyone have some idea? thanks peter

Answer

Calin Drule picture Calin Drule · Feb 6, 2012

The right way to do this is:

[menu setSelectedSegmentIndex:UISegmentedControlNoSegment];