I want to make a UIButton
disable for user touch. Both setEnabled
and setUserInteractionEnabled
can do this. Which is better? How are they different?
Which is better, setEnabled or setUserInteractionEnabled?
6.9k Views Asked by Yi Jiang At
2
enabled
is a property ofUIControl
, which is the superclass forUIButton
.userInteractionEnabled
is a property ofUIView
(which is the superclass ofUIControl
).enabled
has effects on the visual state of the object (grayed out, by default) and is generally the preferred method of disabling a control—visual feedback indicating behaviors is a good thing.There's not much practical upshot beyond that. Code that interacts with your controls is more likely to check if buttons are enabled than if their userInteractionEnabled property is set. Hence using
enabled
is more conventional.