views:

340

answers:

3

I'm running into an issue where I have a UIButton in which I want to track press/release events. So I am tacking on to the Touch Down/Touch Up events. Unfortunately, in certain situations this won't track Touch Up events -- for instance, if an Alert pops up.

- (IBAction)buttonDown:(id)sender;
- (IBAction)buttonUp:(id)sender;

How do I ensure that the view controller is notified when the button goes from pushed/normal state, no matter what the reason?

+2  A: 

Try this method:

[myButton addTarget: target action: @selector(buttonUp:) forControlEvents: UIControlEventTouchUpInside];
Costique
Forgot to mention, I do have both Touch Up Inside and Outside hooked up in IB.
sehugg
A: 
David Kanarek
Nope, that didn't do it either. It usually happens when I pop a UIAlert while the button is held.
sehugg
Actually it did, when I realized I had fat-moused the IB wiring :P
sehugg
A: 

Are you trying to detect if the buttons are being pressed or released while the UIAlert view is currently on top or has it been dismissed and the button presses are no longer responsive?

John Wang
Trying to detect if the UIAlert is displayed while the button is depressed (because when this happens, the button goes back to Normal state but does not fire a Touch Up)
sehugg