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?
You need to track the touch cancel event as well. That should do it.
Edit:Hmmm, what about
UIControlEventAllTouchEvents? You have to add it programmatically. I’m really surprised cancel didn’t do it. You could also try handling-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)eventin your UIViewController.Excellent.