ios uibutton hidden: does this automatically make the button disabled?

Nathan Fraenkel picture Nathan Fraenkel · Jul 9, 2013 · Viewed 9.2k times · Source

I just have a knowledge question about UIButtons / iOS in general.

Let's say you have a UIButton. You set the 'hidden' property to YES. This makes it no longer visible in view, right? But I noticed that while it's no longer visible, it is also no longer clickable either. So, does this mean that setting hidden = YES also sets enabled = NO?

Just curious. Thanks y'all.

Answer

Nirav Gadhiya picture Nirav Gadhiya · Jul 9, 2013

UIButton and all controls inherits common properties from UIView like hidden, backgroundColor, etc.

Class reference of UIView says if any view is hidden then it will not receive input events

Class reference of UIView says:

A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual. Hiding a view with subviews has the effect of hiding those subviews and any view descendants they might have. This effect is implicit and does not alter the hidden state of the receiver’s descendants.

you can find this over Here.