I\'m trying to put two buttons on the screen and set them up so that the user needs to press them both at the same time in order to trigger an action.
This is simila
Since UIButton
is a subclass of UIControl
, it inherits the touchInside
property of UIControl
. Furthermore, when UIButton
sends the touch-up-inside action, it still responds to touchInside
with YES
. So you can just hook both buttons up to this action:
- (IBAction)buttonWasTouched:(id)sender {
if (self.button1.touchInside && self.button2.touchInside) {
[self launchNukes];
}
}
By default, Interface Builder hooks up the touch-up-inside event when you control-drag. If you would rather launch the nukes the moment the second button is simultaneously touched, hook up the touch-down events. You do this by control-clicking the buttons instead of control-dragging them.