iPhone没有拨打给定的号码,我想知道为什么?
我有这个代码片段iPhone没有拨打给定的号码,我想知道为什么?,iphone,objective-c,ios,Iphone,Objective C,Ios,我有这个代码片段 NSString *number = [NSString stringWithFormat:@"tel://%@", phoneNumber]; NSLog(@"%@", number); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]]; NSLog输出为 2011-11-21 15:32:49.621 Tittle-Tattle[1743:707] tel://
NSString *number = [NSString stringWithFormat:@"tel://%@", phoneNumber];
NSLog(@"%@", number);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]];
NSLog输出为
2011-11-21 15:32:49.621 Tittle-Tattle[1743:707] tel://0413 883 245
2011-11-21 15:32:56.914 Tittle-Tattle[1743:707] tel://0413 873 245
一切似乎都很好,但我的应用程序并没有切换到手机应用程序并开始拨打这个号码。任何建议
谢谢url字符串必须没有任何空格。使用您的示例,代码如下所示:
NSString *number = [[NSString stringWithFormat:@"tel://%@", phoneNumber] stringByReplacingOccurencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]];
您在拨号前是否尝试过删除电话号码中的空格?@sosborn谢谢您的帮助,请回答我将接受并投票!谢谢,干杯