【发布时间】:2016-04-02 07:50:10
【问题描述】:
我也是 ios 和目标 c 的新手,我知道我的问题很简单,但我发现没有解决问题,我有一个静态值的方法,现在我想通过将值传递给该方法来使其动态化,所以有朋友可以告诉我如何编写带参数的方法以及如何调用它。我的代码如下:
-(void)phoneNumberLabelTap
{
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",fonlabel.text]];
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) {
[[UIApplication sharedApplication] openURL:phoneUrl];
} else {
UIAlertView * calert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Call facility is not available!!!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[calert show];
}
}
我想给这个方法加一个参数, 我在下面调用这个方法,
fonlabel.userInteractionEnabled = YES;
homeLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(phoneNumberLabelTap)];
[fonlabel addGestureRecognizer:tapGesture];
[homeLabel addGestureRecognizer:tapGesture];
【问题讨论】:
-
我不明白如何调用方法,谁能帮忙代替只发布链接...???
标签: ios objective-c methods