Iphone iBaction不起作用

Iphone iBaction不起作用,iphone,ibaction,Iphone,Ibaction,我有两个按钮没有执行IBAction,这是他们编程要做的。我在Interface Builder中正确连接了它们,但当我在模拟器或电话中单击它们时,它们不会执行任务。没有撞车,什么也没有。这是我的密码 MapDetailInfo.h: @interface MapDetailInfo : UIViewController { IBOutlet UILabel *name; IBOutlet UITextView *address; NSString * nameText; NSString *

我有两个按钮没有执行IBAction,这是他们编程要做的。我在Interface Builder中正确连接了它们,但当我在模拟器或电话中单击它们时,它们不会执行任务。没有撞车,什么也没有。这是我的密码

MapDetailInfo.h:

@interface MapDetailInfo : UIViewController {

IBOutlet UILabel *name;
IBOutlet UITextView *address;
NSString * nameText;
NSString * addressText;
NSString * stringOne;
NSString * stringTwo;


IBOutlet UILabel *phoneNumber;

}

@property (retain, nonatomic) IBOutlet UILabel *name;
@property (retain, nonatomic) IBOutlet UITextView *address;
@property (nonatomic, copy) NSString * nameText;
@property (nonatomic, copy) NSString * addressText;
@property (retain, nonatomic)  NSString * stringOne;
@property (retain, nonatomic)  NSString * stringTwo;
@property (retain, nonatomic) IBOutlet UILabel *phoneNumber;

- (IBAction)callPhone:(id)sender;
- (IBAction)getDirections:(id)sender; 


@end
MapDetailInfo.m:

@implementation MapDetailInfo
@synthesize name, address, nameText, addressText, phoneNumber, stringTwo, stringOne;
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *myWords = [addressText componentsSeparatedByCharactersInSet:
                    [NSCharacterSet characterSetWithCharactersInString:@"("]
                    ];

stringOne = [myWords objectAtIndex:1];
stringTwo = @"("; 


stringTwo = [stringTwo stringByAppendingString:stringOne];


self.name.text = nameText;
self.address.text = [myWords objectAtIndex:0];
self.phoneNumber.text = stringTwo; 

  UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self 
           action:@selector(callPhone:)
 forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Call Shop" forState:UIControlStateNormal];
button.frame = CGRectMake(104.0, 332.0, 160.0, 40.0);
[self.view addSubview:button];


}


- (IBAction)callPhone:(id)sender {

NSString *URLString = [@"tel://" stringByAppendingString:stringTwo];

NSURL *URL = [NSURL URLWithString:URLString];

[[UIApplication sharedApplication] openURL:URL];
}

- (IBAction)getDirections:(id)sender {
 [[UIApplication sharedApplication] openURL:
 [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=Current    Location&daddr=%@",self.address.text]]];    
}
我正在从地图中的注释中提取此视图。如果这两个按钮不执行其任务,则一切都会正常工作。任何帮助都将不胜感激。谢谢

我在你的代码中没有看到任何UIButton。你用过吗

编辑:

我建议您使用按钮,因为这是特定的用途。是的,您仍然可以使用标签并按照相同的过程调用这些方法

你连接插座的方式一定有问题

我建议您遵循本Youtube链接的教程4、5和6。

按钮不起作用的原因是URL不正确。如果遇到相同的问题,请确保您的电话号码URL为:

@"tel://5555555"
我有括号和破折号在我的里面,这就是为什么它不会拉起来。我的谷歌网址也有一个错误


谢谢

尝试在操作中添加断点或日志语句,以查看是否忽略了它们的内容,或者实际上没有调用它们。是否将这些iActions连接到按钮?是。我在Interface Builder中放置了两个按钮,并将它们连接到适当的帐户适当的方式。。。内部修补?正确。。。“适当”是指我将按钮连接到我希望他们在内部进行润色时执行的操作。我在interface builder中放置并连接了两个按钮。你认为在我的代码中这样做会更好吗?不,如果他不需要,他不应该@编辑:伊丹是第一个…:他可以使用带有标签的方法,但他的全部目的不是要有一个按钮来调用方法吗?我建议他用你的钮扣。认真地所以我添加了一个UIButton,同样的事情发生了。单击按钮,没有任何操作。@Legolas:按钮位于IB文件中,并连接到一个方法,它确实显示并执行该方法,不需要声明它。