在应用问题中拨打电话号码

时间:2012-12-31 01:08:43

标签: iphone objective-c ios

我有以下代码:

phoneNumber = (NSString*)CFBridgingRelease(ABMultiValueCopyValueAtIndex(phones, i));
NSString *phoneNumberURLString = [[NSString alloc] initWithFormat:@"tel://%@", phoneNumber];
            NSURL *phoneURL = [[NSURL alloc] initWithString:phoneNumberURLString];
            [[UIApplication sharedApplication] openURL:phoneURL];

然而,问题在于,有时某个电话号码不会被呼叫:例如,如果phoneNumber是(520)123-1232,那么这不会拨打电话。有关如何对电话号码格式进行标准化以使此方法适用于所有情况的任何想法吗?

1 个答案:

答案 0 :(得分:0)

这是数字中的空格。空格不是有效的URL字符。必须将其编码为%20