3
我有一种看法,单击时应提示用户拨打电话。我尝试使用下面的代码:iOS:提示用户拨打电话
NSString *phoneNumber = [@"tel://" stringByAppendingString:locPhone];
NSString *phoneString = [phoneNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
phoneString= [phoneString stringByReplacingOccurrencesOfString:@"(" withString:@""];
phoneString= [phoneString stringByReplacingOccurrencesOfString:@")" withString:@""];
phoneString= [phoneString stringByReplacingOccurrencesOfString:@"-" withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneString]];
我知道那是达到了代码,而“phoneString”的终极价值是一个10位数的电话号码。没有错误,但没有任何反应。我错过了什么?
编辑:我现在看到,canOpenURL返回NO。这是因为我在模拟器上运行它?
您是如何知道代码已达到的? – aforaudrey
在我看来,这应该工作,没有问题,如果你调试,你确定它得到这些线? –
你应该总是首先使用'canOpenURL'。它是否返回YES? – Felix