Hello -

I am trying to toggle a button with three states.
In IB I have it set to “off”

In the code I toggle as such:

func toggleStatus() {
        if(product.favorite == false && product.avoid == false){
            product.favorite = true
            product.avoid = false
            favoriteButton.setImage(UIImage(named: "Favorites-On"), forState: 
.Normal)
            
            
        }else if(product.favorite == true && product.avoid == false){
            product.favorite = false
            product.avoid = true
            favoriteButton.setImage(UIImage(named: "Avoids-On"), forState: 
.Normal)
        
        }else {
            product.favorite = false
            product.avoid = false
            favoriteButton.setImage(UIImage(named: "Favorites-Off"), forState: 
.Normal)
            
        }
    }

When my screen comes up it is correctly in the off state.
When I touch it, it correctly goes to Favorites-On
When I touch it again, it correctly goes to Avoids-On
HOWEVER, when I next touch it, it briefly shows “Favorites-On” before going to 
“Favorites-Off”

Why is it flashing like that?
Thanks



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to