Christian Gossain
Christian Gossain

Reputation: 5972

Disabling User Interaction with a segmented control?

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?

Upvotes: 2

Views: 3935

Answers (4)

mfaani
mfaani

Reputation: 36287

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 and add a gray overlay in addition to disabling/enabling the segment.

So for me isEnabled was a better alternative

Upvotes: 1

Sanjay Mishra
Sanjay Mishra

Reputation: 702

In swift 4.2

set yourSegmentedControlName.isUserInteractionEnabled = false

Upvotes: 1

Jacob Relkin
Jacob Relkin

Reputation: 163238

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

Upvotes: 7

Björn Marschollek
Björn Marschollek

Reputation: 9999

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

Upvotes: 6

Related Questions