ios - 可以给UILabel打电话吗?

标签 ios uibutton uilabel parse-platform phone-call

我正在以编程方式在我的应用程序中将Parse.com中的String提取到UILabel中。
字符串是电话号码。所以我的问题是,是否可以对单击后的UILabel进行操作以进行 call ..还是我必须从Button中获取数据,或者更好,这可能吗?

如果有可能,我应该怎么做?有人有我可以关注的示例或教程吗?
任何帮助,将不胜感激。
谢谢!

最佳答案

您的问题分为两部分:

  • 将UILabel粘贴到磁带时执行任何操作
  • 执行电话操作(在第一部分中使用的操作)

  • 首先,要在粘贴标签时执行操作,必须向该标签添加轻击手势识别器:
    phoneNumberLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = 
       [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(phoneNumberLabelTap)];
    [phoneNumberLabel addGestureRecognizer:tapGesture];
    

    然后,您必须实现您的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];
        }
    }
    

    关于ios - 可以给UILabel打电话吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22312792/

    相关文章:

    ios - 无法在 Collection View 中显示数组 (Swift 4)

    ios - 从静态子项目访问委托(delegate)

    ios - 大文件的 RNCryptor 内存问题

    ios - Swift,触摸 UIButton 并触摸另一个

    ios - 如何在单击同一个 UIbutton 时更改 UIButton 背景图像?

    ios - 如何使用步进 slider 在 slider 拇指上添加 UILabel?

    ios - Swift xcode 6 label.text 在 NSURLSession 中没有改变

    iOS 获取 UILabel 中的第一个属性行

    ios - 后台运行3分钟后闹钟不响

    iphone - iOS UIButton 如何制作这样漂亮的按钮?