Objective c uibutton是否可以同时具有插座和动作?

Objective c uibutton是否可以同时具有插座和动作?,objective-c,uibutton,action,outlet,Objective C,Uibutton,Action,Outlet,我有两个ui按钮,它们通过switch语句更改文本标签(仅为测试目的执行了第一种情况): 因此,当按下ui按钮时,将执行一项操作: - (IBAction)phoneButtonAction:(id)sender { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",_emailButton.titleLabel.text]]]; }

我有两个
ui按钮
,它们通过switch语句更改文本标签(仅为测试目的执行了第一种情况):

因此,当按下
ui按钮时,将执行一项操作:

- (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"]];
}
更改文本标签会起作用,但不会影响操作。 是不是因为每个
ui按钮都只能有一个出口或一个操作?

如果是这样的话,我该如何执行所需的操作?

模拟机上的
mailto:
tel:
URL方案不起作用。仅限设备。

以前的:

您是否向UIButtons添加了任何操作

[_phoneButton addTarget:self
                 action:@selector(phoneButtonAction:)
       forControlEvents:UIControlEventTouchUpInside];
[_phoneButton addTarget:self
                 action:@selector(emailButtonAction:)
       forControlEvents:UIControlEventTouchUpInside];

-(IBAction)phoneButtonAction:(id)发件人{[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@“tel://%@,_-emailButton.titleLabel.text]];-(IBAction)emailButtonAction:(id)发件人{[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@]mailto://devprograms@apple.com“]];您是说您已经在Interface builder中设置了这些操作?我可以看到您的代码中定义了操作。我是问您是否已经对UIButtons进行了编程以发送这些操作…但您是说这些操作没有被调用?它们应该被调用,因为所有连接都在那里,但是当我运行模拟器和pres时这两个按钮中的任何一个都不会发生任何事情。
[_phoneButton addTarget:self
                 action:@selector(phoneButtonAction:)
       forControlEvents:UIControlEventTouchUpInside];
[_phoneButton addTarget:self
                 action:@selector(emailButtonAction:)
       forControlEvents:UIControlEventTouchUpInside];