You can click the Taped button using the Tag value. Suppose you have a tree button for an example: -
@property (nonatomic, strong) UIButton *btn1;
@property (nonatomic, strong) UIButton *btn2;
@property (nonatomic, strong) UIButton *btn3;
Then set the Tag of Button as: -
btn1.tag=1;
btn2.tag=2;
btn3.tag=3;
and set Same for each button IBActionand: -
[btn1 addTarget:self action:@selector(difficultyButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[btn2 addTarget:self action:@selector(difficultyButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[btn3 addTarget:self action:@selector(difficultyButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- (IBAction)difficultyButtonPressed:(UIButton*)sender
{
NSLog(@"Button tag is %d",sender.tag);
if(sender.tag==1)
{
[self performSegueWithIdentifier:@"mainGameTurnGuess_FirstButtonIdentirier" sender:sender];
}
else if(sender.tag==2)
{
[self performSegueWithIdentifier:@"mainGameTurnGuess_secondButtonIdentirier" sender:sender];
}
else
{
[self performSegueWithIdentifier:@"mainGameTurnGuess_ThirdButtonIdentirier" sender:sender];
}
}
For information
id IBAction, Button : -
- (IBAction)difficultyButtonPressed:(id)sender {
UIButton *button = (UIButton *)sender;
NSLog(@"Button tag is %d",button.tag);
}