2012-12-31 77 views
1

我有以下代碼:主叫電話號碼

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,那麼這不會撥打電話。任何關於如何標準化電話號碼格式的想法,以便這種方法適用於所有情況?

+0

它只是你指定的數字嗎?哪些號碼不被呼叫? – Jeeter

+0

你在模擬器或設備上運行...看看:http://stackoverflow.com/questions/3282778/make-a-call-from-my-iphone-application?rq=1 – Groot

+0

運行它設備 – aherlambang

回答

0

它是數字中的空格。空格不是有效的URL字符。它必須編碼爲%20

+0

我沒有文檔方便。查看NString文檔中名爲「stringByAddingPercentEscapes」的方法。 – rmaddy