gpt4 book ai didi

ios - 可以给UILabel打电话吗?

转载 作者:行者123 更新时间:2023-12-01 17:53:39 25 4
gpt4 key购买 nike

我正在以编程方式在我的应用程序中将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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com