This is probably the most frustrating situation I've dealt with, and it probably has the simplest solution.
I've got this UIButton
storeB
that gets properly initialized during the viewDidLoad:
call of my UIViewController
. Before I create the button, I create 5 other buttons.
During viewDidLoad:
, I run this method called setupFBConditions
which determines whether my forwardB
button object should have an alpha
of 0.5 with userInteractionEnabled
set to 0. When this is the case, the button looks and performs the way it's supposed (essentially, like it's not there).
Furthermore, during this particular animation that is performed on one of my UIView
objects, I decided to set the userInteractionEnabled
property of my restartB
object to 0 (so that no interaction occurs during the animation. That performance is also successful.
However, when I decide to write:
storeB.userInteractionEnabled = NO;
storeB.alpha = 0.5;
at the start of the animation (with the intention to keep this state till the game finishes or restartB
is tapped again), and NSLog
the button object, the log says that the userInteractionEnabled
property is NO
and alpha
is 0.5, just like it should be. However, at no point do these properties get reflected to the UI.
storeB
is my not even my last view to be added to the hierarchy (although it is the last UIButton
). I have no idea why these changes are not taking effect.
I'm not going to post any more code because there's nothing to post besides the two lines above. It's that apparently simple of a problem + solution.
************ UPDATE **************
Here is the log report at the end of one of my swipe gesture actions (after storeB.userInteractionEnabled = NO;
):
<UIButton: 0x1585ae80; frame = (270 8; 42 42); alpha = 0.5; opaque = NO;
userInteractionEnabled = NO; layer = <CALayer: 0x15899da0>>
<UIView: 0x1592bba0; frame = (0 0; 320 568); layer = <CALayer: 0x15934ae0>>
The frame is correct, the alpha and interaction settings are correct, and the superview frame (0,0,320,568) is exactly what it's supposed to be.
*********** SECOND UPDATE **************
In case anyone finds this useful...check the _retainCount
property of your UIView
/UIButton
and see if it looks unusually high when taking into account all the operations done to the object. My retain count was 4 when it should have been 2, so every time I changed the property (of what I thought was my first instance of storeB
), it was actually only affecting the second instance (that I didn't even know existed).