2

I want to enable and disable user interaction with a UISegmented Control. I noticed that its superclass UIControl has a property called "enabled" is this what I need to set in order to disable/enable my control?

mfaani
  • 33,269
  • 19
  • 164
  • 293
Christian Gossain
  • 5,942
  • 12
  • 53
  • 85

4 Answers4

7

Yes, the enabled property is what you want. You can also use userInteractionEnabled as well, but I think that enabled will suffice.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
  • 2
    I found that `enabled` alone isn't enough. A disabled segmented control will still receive touches and change its segment. It needs the `userInteractionEnabled` set to `NO` too. – nevan king Jun 21 '13 at 18:55
6

Yes, for example. You can also use [segmentedControl setUserInteractionEnabled:NO]

Björn Marschollek
  • 9,899
  • 9
  • 40
  • 66
1

In swift 4.2

set yourSegmentedControlName.isUserInteractionEnabled = false

Sanjay Mishra
  • 672
  • 7
  • 17
0

Upon tapping a segment I was making a network call and during the network call I wanted to disable the segment and also have it greyed out a bit.

Using isUserInteractionEnabled will only disable/enable the segment.

But using isEnabled will gray add a gray overlay in addition to disabling/enabling the segment.

So for me isEnabled was a better alternative

mfaani
  • 33,269
  • 19
  • 164
  • 293