美文网首页iOS
iOS开发之拨打电话

iOS开发之拨打电话

作者: 1c7d21358574 | 来源:发表于2015-12-07 12:39 被阅读262次

在开发过程中,相信很多人都遇到过这个小需求吧。那么废话不多说,直接上代码。

- (void)viewDidLoad {
  [super viewDidLoad];

  UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
  [self.view addSubview:webView];
  
  NSURL *url = [NSURL URLWithString:@"tel://10010"];

  // 1、此方法打完电话后不能回到APP
  // [[UIApplication sharedApplication] openURL:url];

  // 2、此方法使用了Apple的私有API,极大可能无法上架AppStore
  // url = [NSURL URLWithString:@"telprompt://10010"];

  // 3、一般使用webView打电话
  [webView loadRequest:[NSURLRequest requestWithURL:url]];
}

赶紧打开Xcode码代码吧,O(∩_∩)O~

相关文章

网友评论

    本文标题:iOS开发之拨打电话

    本文链接:https://www.haomeiwen.com/subject/fglehttx.html