为什么我的代码不适用于iphone 5

时间:2013-01-28 11:10:18

标签: iphone xcode call

所以我创建了一个调用数字的应用程序:

NSString *cleanedString = [[number componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", escapedPhoneNumber]];
UIWebView *mCallWebview = [[UIWebView alloc] init]  ;
[self.view addSubview:mCallWebview];
[mCallWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

然而,iPhone 5的测试人员报告说,在主要工作正常的情况下,它不能在手机上工作。他没有任何崩溃或任何事情。

谢谢你!

3 个答案:

答案 0 :(得分:2)

  NSString *number = YOUR-NUMBER;       
  NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",number]];

  [[UIApplication sharedApplication] openURL:url];

尝试使用此代码,它将在完成调用后导航回您的应用

答案 1 :(得分:1)

代码中使用的tel:网址架构未正确使用,请移除//

NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", escapedPhoneNumber]];

答案 2 :(得分:0)

您可以查看此代码。我希望这会对您有所帮助。

NSString *phoneNo = @"your phone no";
NSString *strAppend  = [@"tel:" stringByAppendingString:phoneNo];
[[UIApplication sharedApplication]
  openURL:[NSURL URLWithString:strAppend]];
相关问题