iphone - 如何以编程方式调用电话?

标签 iphone objective-c ios

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

为此我找到了这样的代码。

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

在iphone sdk 3.0 和iphone 2.0 中也可以吗

有什么可以帮忙的吗

提前谢谢你。

最佳答案

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

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

关于iphone - 如何以编程方式调用电话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4582327/

相关文章:

iphone - 在我的 App 中的 App Store 中打开我的应用程序列表

ios - 电子邮件、密码、姓名的 UITextField 验证

iphone - 如何使用 glRotatef() 和 glTranslatef() 在 3D 世界中增量移动

ios - 类型 'Self.ManageableType' 的值没有成员 'uid'

ios - Swift 3 UILabel 获取实际高度(intrinsicContentSize)

iphone - 验证/检查 iPhone 上是否已安装配置文件

iphone - UITableViewCell 附件类型在点击时选中并设置其他未选中

objective-c - Objective C 如何获取 Facebook 访问 token

ios - 应用进入后台IOS?

iOS Safari 显示已安装的应用程序。这是如何运作的?元标签?