I have four segments in my UISegmentedControl. I am trying to programmatically set the selected state of the third and fourth segments at the same time if the user has selected the first segment.
Example: In a given segmented control, if the user selected segment A, then C, D should be selected.
I looked into Apple's methods but found none that match my requirement. I am looking for a method that would look like-
Any help on this is much appreciated.
-(void) setSelected: (BOOL) selected forSegmentAtIndex: (NSUInteger) segment
Parameters
enabled
YES to select the specified segment or NO to unselect the segment. By default, segments are unselected.
segment
An index number identifying a segment in the control. It must be a number between 0 and the number of segments (numberOfSegments) minus 1; values exceeding this upper range are pinned to it.
Swift 4.0
segmentedControl.selectedSegmentIndex = index
Use setSelectedSegmentIndex
like so -
[mySegmentControl setSelectedSegmentIndex:index]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With