I have 2 UIButtons
that change their text label with a switch statement (have only done the 1st case for testing purposes):
switch (_itemNumber)
{
case 0:
[_phoneButton setTitle:@"201-612-5480" forState:UIControlStateNormal];
[_emailButton setTitle:@"aacenter@bergen.edu" forState:UIControlStateNormal];
self.title = @"Acdmc. Adv. Center";
break;
default:
break;
}
So when the UIButton
is pressed an action will be performed:
- (IBAction)phoneButtonAction:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",_emailButton.titleLabel.text]]];
}
- (IBAction)emailButtonAction:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
}
Changing the text label works and, but not the action.
Is it because you can only have an outlet or an action for each UIButton
?
If so how can I manage to perform the desired action?