使用按钮和文本字段/视图打开电话(呼叫)(iPhone)
这可能吗?
该应用程序将有一个按钮和一个文本字段或文本视图。
用户在文本字段或文本视图中输入电话号码。当用户完成后,用户按下按钮,这将打开“电话”按钮并拨打该号码。
我该怎么做?如果可以请提供一些代码! :)
先感谢您!
Would this be possible?
The app will have a button and a Text Field or a Text View.
The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Phone button and place the call to the number.
How would I do this? If possible please provide some code! :)
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这段代码,这应该可以正常工作!
Take a look at this code, This should work fine!
您可以将电话号码格式化为
tel://
URL。因此,如果您有一个文本字段(出于我们的目的,MyTextField
):You can format a phone number as a
tel://
URL. So, if you have a text field (MyTextField
for our purposes here):iPhone 支持 tel: URI 方案,如 RFC 3966 所定义。因此,一个要求电话拨打号码“12345”的简单示例是:
这应该会导致设备切换到正常的电话应用程序并拨打该号码。您需要验证文本字段以检查非法输入;该规范实际上允许使用相当多的字符(请参阅第 5 页的正式语法),但作为第一个测试,您可能需要删除任何不是数字的内容。
The iPhone supports the tel: URI scheme, as defined by RFC 3966. So a simple example that would ask that the phone call the number '12345' would be:
That should cause the device to switch over to the normal Phone application and dial the number. You'll want to validate the text field to check for illegal entries; the spec actually allows quite a few characters (see the formal grammar on page 5), but as a first test you might want to remove anything that isn't a number.