Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone没有拨打给定的号码,我想知道为什么?_Iphone_Objective C_Ios - Fatal编程技术网

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谢谢您的帮助,请回答我将接受并投票!谢谢,干杯