I have a UIButton
which is acting as a "confirm" button. Basically, I want it to require two taps to trigger its action, so the first time you tap it, the picture will change to an "are you sure" type image, at which point, a second tap would trigger the action.
This works fine, but I want to set it up so that tapping anywhere outside of the button resets it back to the first image again so it requires 2 taps again.
Is there any way to detect if the user touches outside of a UIButton
; perhaps is there a way to give it "focus" and check for a focus exit?
I thought of UITouch
, but that will only send its event to the view you are touching that responds to it.
Attach a UITapGestureRecognizer
to the button's superview (probably the view controller's content view.) Set userInteractionEnabled
to true. Put your code that resets the button in the handler for the tap gesture recognizer.