Button Image Behavior
Button Image Behavior
- Subject: Button Image Behavior
- From: James Cicenia <email@hidden>
- Date: Wed, 19 Aug 2015 20:46:45 -0500
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 (email@hidden)
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:
This email sent to email@hidden