Detect phone calls in iPhone
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 开发者_如何学Goway 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).
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
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"tel:0800-CALL-ME"]];
Check the class description of UIApplication for more info.
精彩评论