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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…