Search code examples
iosobjective-cuisegmentedcontrol

UISegmentControl Selection Empty


Hi When i create Segment control I need to show UISegment control without selection. I tried following code but no luck.

[_userSeg setSelectedSegmentIndex:nil];

and

[_userSeg setSelectedSegmentIndex:-1];

Solution

  • Hi Check below code Hope It works.

    Objective C:

    [_userSeg setSelectedSegmentIndex:UISegmentedControlNoSegment];
    

    Swift:

    userSeg.selectedSegmentIndex = Int(UISegmentedControlNoSegment)