从我的iPhone应用程序拨打电话 [英] Make a call from my iPhone application

查看:128
本文介绍了从我的iPhone应用程序拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了通过点击我酒店的一排描述性表格来拨打电话的能力;我通过在方法didSelectRowAtIndexPath中编写以下代码来使用URL方案:

I have implemented the ability to make a call from clicking on a row of descriptive tableview of my hotel; I used the URL scheme by writing the following code in method "didSelectRowAtIndexPath ":

NSString *phoneNumber=element.phone;                                       
[NSString *phoneNumberScheme = [NSString stringWithFormat:@"tel:%@ ", phoneNumber];
NSlog(phoneNumberScheme);                      
phoneNumberScheme = [phoneNumberScheme stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumberScheme]];

没有错误!使用NSlog,我确认该号码已被正确读取,因此它(确实在控制台上显示电话:1-408-555-5555)。问题是什么都没发生!!!

No error! With NSlog I verified that the number was read correctly, and so it is (indeed on console appears tel:1-408-555-5555). The problem is that nothing happens!!!

此时(也基于我在网上看到的东西)我怀疑我无法测试这个东西在模拟器上!我做错了什么或不能在模拟器上测试这个URL方案?!

At this point (also based on something I read on the web) I have a doubt that I can't test this thing on simulator! Am I doing something wrong or can't I test this "URL scheme" on the simulator?!

推荐答案

扩展seanny94的回答:模拟器不支持很多iOS的URL方案,包括Phone,Maps,Youtube和SMS应用程序。对于没有手机功能的iPod touch和iPad等设备也是如此;在通过 -openURL:使用任何URL方案之前,您应该使用 -canOpenURL:检查该方案的支持,其中将返回 YES ,具体取决于当前设备是否支持您正在使用的URL方案。

To expand on seanny94's answer: the simulator doesn't support a lot of iOS's URL schemes, including those for the Phone, Maps, Youtube, and SMS apps. This is also the case for devices like the iPod touch and the iPad, which don't have phone capabilities; before using any URL scheme via -openURL:, you should check for support for that scheme using -canOpenURL:, which will return YES or NO depending on whether the current device supports the URL scheme you're using.

这篇关于从我的iPhone应用程序拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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