我使用的是iOS6,我无法调用这个号码:*222*20#
这是我的代码:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:*222*20#"]]];
当我运行上面的脚本时没有任何反应?
又或许,拨号号码有一些限制?!
最佳答案
这是因为您的号码包含*
和#
。
To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number. If your application receives URL strings from the user or an unknown source, you should also make sure that any special characters that might not be appropriate in a URL are escaped properly. For native applications, use the stringByAddingPercentEscapesUsingEncoding: method of NSString to escape characters, which returns a properly escaped version of your original string.
请查看iPhoneURLScheme了解更多详情。
关于ios - 无法使用 Objective-C 调用号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14377311/