Your action can be implemented like this:
- (IBAction) buttonTapped: (id) sender
// you can also replace id with UIButton*
Then inside this method you can check by -isEqual: method
- (IBAction) buttonTapped: (id) sender
{
if ([sender isEqual:referenceToOneOfYourButtons]) {
// do something
}
else if ([sender isEqual:referenceToTheOtherButton]) {
...
}
}
Alternatively you can set up different values to tag property of buttons and then:
- (IBAction) buttonTapped: (UIButton*) sender
{
const int firstButtonTag = 101;
const int otherButtonTag = 102;
if (sender.tag == firstButtonTag) {
...
}
else if (sender.tag == otherButtonTag) {
...
}
}
You need to set up this tag either in your .xib or in code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…