Iphone 应用程序内的呼叫电话号码问题

Iphone 应用程序内的呼叫电话号码问题,iphone,objective-c,ios,Iphone,Objective C,Ios,我有以下代码: phoneNumber = (NSString*)CFBridgingRelease(ABMultiValueCopyValueAtIndex(phones, i)); NSString *phoneNumberURLString = [[NSString alloc] initWithFormat:@"tel://%@", phoneNumber]; NSURL *phoneURL = [[NSURL alloc] initWithString:phon

我有以下代码:

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

然而,问题是,有时某个电话号码不会被呼叫:例如,如果电话号码是520 123-1232,则该号码不会呼叫该电话。有没有关于如何标准化电话号码格式以使此方法适用于所有情况的想法?

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

只是你指定的那个号码吗?哪些号码不会被呼叫?你是在模拟器中运行还是在设备上运行…看:这不仅仅是我指定的号码。。基本上,以下+15208238172的所有数字都有效。。然而,如果它是像5200828172的东西,那么它就不起作用了。我手头没有文档。在NString文档中查找名为stringByAddingPercentEscapes的方法。