Perhaps instead of UIButton you should use UIView with 2 UITapGestureRecognizers
? One of them would have numberOfTapsRequired = 2
, the other one would have numberOfTapsRequired = 1
. Use method requiresGestureRecognizerToFail to make sure that you won't have them both calling their target methods. Then you can add any logic you want to the tap handling.
EDIT: Actually, although the above answer is kind of workaround, it will fail if user taps 3 or more times. And since you can't really make a gesture recognizer for every number of taps from 1 to infinity, it will fail in some cases. Try this:
btn.enabled = NO;
if (btn.tag == 0) {
// change to pause button
// start process
btn.tag = 1;
}
else if (btn.tag == 1) {
// change to play button
// stop process
btn.tag = 0;
}
btn.enabled = YES;