iOS

iOS开发之拨打电话

2015-12-07  本文已影响262人  1c7d21358574

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

- (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~

上一篇 下一篇

猜你喜欢

热点阅读