Xcode iOS:从应用程序拨打号码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12657628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode iOS: Calling a number from the app
提问by iDev
I across the following code:
我通过以下代码:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8005551212"]];
on : Making phone calls on iPhone
But, it does not work for me in the simulator. I have connected the IBAction(callphone) to the ViewController(TouchUpInside). I am now not sure, is it because I am checking my code in simulator? I do not get a dialog box. Please advice.
但是,它在模拟器中对我不起作用。我已将 IBAction(callphone) 连接到 ViewController(TouchUpInside)。我现在不确定,是不是因为我在模拟器中检查我的代码?我没有得到一个对话框。请指教。
I tried putting log statements and the action does get called since the log stamtments that I wrote to test is being printed
我尝试放置日志语句并且该操作确实被调用,因为正在打印我写给测试的日志语句
回答by Mark Granoff
Can you make a phone call from your Mac? No. That's why the simulator doesn't work when you try to open a tel://URL. You must do this from a device that can make a call: an iPhone, but not an iPad or iPod touch.
您可以从 Mac 拨打电话吗?不。这就是当您尝试打开tel://URL时模拟器不起作用的原因。您必须使用可以拨打电话的设备执行此操作:iPhone,但不能使用 iPad 或 iPod touch。

