sayguh
sayguh

Reputation: 2550

Strange highlight animation occurring for UIButton

I have a IBOutletCollection setup that contains 8 UIButtons. All of the buttons have "Shows Touch on Highlight" property set so they glow white when touched.

When I touch a button I have it set to hidden. And then when three buttons have been hidden I call a method that enumerates through the IBOutletCollection and unhides any hidden buttons.

The weird thing, is that the third button that I touched, when it gets hidden (no matter which of the 8 it is) redisplays with a slight animation. It glows white briefly as if it was highlighted?

Why would just one of them glow white when it is unhidden? Here is the code I use to unhide

for (UIButton *stockButton in stockButtonCollection) {               
    [stockButton setBackgroundImage:[UIImage imageNamed:@"original.png"] forState:UIControlStateNormal];

        if (stockButton.hidden) stockButton.hidden = FALSE;
}

Upvotes: 0

Views: 366

Answers (2)

logancautrell
logancautrell

Reputation: 8772

Try adding a slight delay before you unhide the buttons, like 0.5 seconds. This will allow the animation to finish for the Shows Touch on Highlight. You can play with the number and probably crank it down to 0.3 or so.

Something like this

    [self performSelector:@selector(unhideButtons) withObject:nil afterDelay:0.5f];

Upvotes: 1

NightCoder
NightCoder

Reputation: 1149

check if that button does not detect the touch two times "at once". If it is the case, disabling the button while hiding it would solve your issue.

Upvotes: 2

Related Questions