我有这段代码,
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
一切似乎都没问题,但是我的应用程序没有切换到手机应用程序并开始拨打此号码。任何建议。
由于
答案 0 :(得分:2)
url字符串必须没有任何空格。使用您的示例代码将显示为:
NSString *number = [[NSString stringWithFormat:@"tel://%@", phoneNumber] stringByReplacingOccurencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]];