检测 iPhone 中的电话
我正在开发一个应用程序,其中用户可以输入电话号码。后来,在查看输入的信息时,我在 UITextView 中显示电话号码,它会自动检测电话号码。
在 iPhone 中,当用户按下电话号码时,系统会自动询问他是否要拨打电话。我不需要做任何事情就可以发生这种情况。
问题是... iPod 和 iPad 中会发生什么?默认行为是什么?有没有办法检测用户按下了电话号码,并输出 UIAlertView 说“不可用的操作”或类似的内容?
或者,当用户在没有默认功能的情况下按下屏幕上的“某物”时,有没有办法获得该行为?例如...用户按下一个按钮,它会自动拨打 911(我不会拨打那个号码,这只是一个例子)。
感谢您的回答。我有点害怕无法测试我的应用程序的设备中的行为(我没有 iPod 或 iPad)。
I'm developing an app in which, among other things, the user can input a phone number. Later, while seeing the inputed information, I display the phone number in a UITextView which detects the phone number automatically.
In an iPhone, when the user presses the phone number, he is automatically asked if he wants to make a call. This happens without me having to do anything.
The problem is... what happens in iPod and iPad? What is the default behaviour? Is there a way to detect that he user pressed the phone number, and output a UIAlertView saying "Unavailable action" or something like that?
Alternativelly, is there a way to get that behaviour when the user presses "something" in the screen without default functions? For instance... the user presses a button and it automatically calls 911 (I will not call THAT number, it's just an example).
Thanks for the answer. I'm kind of affraid of the behaviours in devices in which I cannot test my app (I don't have iPod nor iPad).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 UITextView 确实处理 URL 上的点击是可能的。在无法呼叫某人的设备上,UITextView 根本不执行任何操作。
您只需打开相应的 URL 即可自行拨打号码,在您的情况下,这将是
检查 UIApplication 的类描述以获取更多信息。
I do not think that it's possible to catch if UITextView does handle a click on an URL. On a device without the possibility to call someone the UITextView simply does nothing.
You can call numbers yourself simply by opening the respective URL, in your case this would be
Check the class description of UIApplication for more info.