adr*_*nry 3 phone-call uibutton uilabel ios parse-platform
我正在我的应用程序中以编程方式从 Parse.com 获取字符串到 UILabel 中。该字符串是电话号码。所以我的问题是,是否可以在单击时对 UILabel 进行操作以进行调用。或者我是否必须从按钮中获取数据,或者更好的是,这可能吗?
如果可以的话我该怎么办?有人有我可以遵循的示例或教程吗?任何帮助,将不胜感激。谢谢!
你的问题分为两部分:
首先,要在粘贴标签时执行操作,您必须向该标签添加点击手势识别器:
phoneNumberLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(phoneNumberLabelTap)];
[phoneNumberLabel addGestureRecognizer:tapGesture];
Run Code Online (Sandbox Code Playgroud)
然后你必须实现你的phoneNumberLabelTap方法:
-(void)phoneNumberLabelTap
{
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phoneNumberLabel.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];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2628 次 |
| 最近记录: |