如何以编程方式拨打电话? [英] How to make a call programmatically?

查看:130
本文介绍了如何以编程方式拨打电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过按钮点击在我的应用程序中以编程方式调用。

I need to call programmatically in my app in a button click.

我发现这样的代码。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-800-555-1212"]];

它是否适用于iphone sdk 3.0和iphone 2.0

Is it work in iphone sdk 3.0 and iphone 2.0 also

可以帮忙吗

提前感谢你。

推荐答案

将电话号码保存在单独的字符串中。

Keep the phone number in a separate string.

NSString *phoneNumber = @"1-800-555-1212"; // dynamically assigned
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
[[UIApplication sharedApplication] openURL:phoneURL];

这篇关于如何以编程方式拨打电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆