0

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];
PREMKUMAR
  • 8,283
  • 8
  • 28
  • 51
PraBa
  • 3
  • 2
  • 1
    Possible duplicate of [UISegmentedControl deselect (make none of the segments selected)](https://stackoverflow.com/questions/2206066/uisegmentedcontrol-deselect-make-none-of-the-segments-selected) – Pratik Sodha Aug 24 '18 at 09:18

1 Answers1

2

Hi Check below code Hope It works.

Objective C:

[_userSeg setSelectedSegmentIndex:UISegmentedControlNoSegment];

Swift:

userSeg.selectedSegmentIndex = Int(UISegmentedControlNoSegment)
PREMKUMAR
  • 8,283
  • 8
  • 28
  • 51
  • just for extra information you can replace Int(UISegmentedControlNoSegment) with -1; that would do the trick. – MhmdRizk Aug 24 '18 at 12:53