setuserinteractionenabled

iOS UIButton - Difference between UIButton setUserInteractionEnabled and setEnabled

此生再无相见时 提交于 2020-01-01 04:40:06
问题 Wait!!!: I know that you may think this question have been asked and answered several time before. But I can guarantee you that this question is unique. Question: In an iOS App, just imagine two buttons are there, like shown in the image bellow, and they have two actions which behaves like a toggling logic. And it's logic may be as follows: - (IBAction)testBtnClicked:(id)sender { if ([self.testBtn isEnabled]) { [self.testBtn setEnabled:NO]; [self.setInteractionBtn setUserInteractionEnabled

Which is better, setEnabled or setUserInteractionEnabled?

穿精又带淫゛_ 提交于 2019-12-03 18:03:21
问题 I want to make a UIButton disable for user touch. Both setEnabled and setUserInteractionEnabled can do this. Which is better? How are they different? 回答1: enabled is a property of UIControl , which is the superclass for UIButton . userInteractionEnabled is a property of UIView (which is the superclass of UIControl ). 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