iOS 调用系统的方法拨打电话

第一种

  • 这种方法是直接拨打,没有提示.通话结束返回当前APP(iOS 9.0 以后),之前的是留在通讯录
        NSURL *phoneURLOne = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"你的电话号码"]];

        [[UIApplication sharedApplication] openURL:phoneURLOne];

第二种

  • 这种使用UIWebView,通话结束返回当前APP,有弹框提示,不过会存在卡顿效果,多次调用会出现多次弹框.且无法进行交互!!(很多APP都是用的这种方法).
      @property (nonatomic,strong) UIWebView * phoneCallWebView;

       懒加载控件
        - (UIWebView *)phoneCallWebView{
        if (!_phoneCallWebView) {
              _phoneCallWebView= [[UIWebView alloc] initWithFrame:CGRectZero];
          }
            return _phoneCallWebView;
        }
       NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"要拨打的电话号码"]];

      [self.phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];

第三种

  • 上架容易被拒,延迟,卡顿.(你还要用?)
    NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",@"15235159830"]];
    
    [[UIApplication sharedApplication] openURL:phoneURL];

个人建议使用第一种,第二种很多APP再用.自己权衡吧

你可能感兴趣的:(iOS 调用系统的方法拨打电话)