R – UIButton subclass continuously highlighted after an popping up and UIAlertView

cocoa-touchiphoneuialertviewuibutton

I am subclassing a UIButton and detecting finger movements, if the user swipes his finger in a certain way I will pop up an UIAlerView.

All good, except that after dismissing the UIAlertView… when the user next touches the UIButton the button goes to it's highlighted state and gets stuck there, continuously highlighted, even when no finger touching it.

Pressing the button again the UIButton begins to behave normally (only highlights when touched).

So I can only presume that an alert during a swipe, screws up the process of events, the touchesEnded never firing perhaps?

If anyone has any ideas on how to 'reset' the button after the swipe so that it behaves as it should, I would be grateful.

Best Answer

Are you resetting your state in touchesCancelled?