zoukankan      html  css  js  c++  java
  • iOS----------拨打电话的3种方式

    iOS实现拨打电话的方式:
     
    方法一、requestWithURL,此方法拨打前弹出提示
    NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
    [self.view addSubview:callWebview];
     

    swift代码:

    let callWebview =  UIWebView()callWebview.loadRequest(NSURLRequest(url: URL(string: "tel:136****0000")!) as URLRequest)
    self.view.addSubview(callWebview)
     

    方法二、openURL(telprompt) ,此方法拨打前弹出提示,据说会导致App Store审核不通过

    NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"telprompt:%@",@"136****0000"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
     

    swift代码:

    方法三、利用openURL(tel),此方法在iOS 10.2之前不会添加弹框,需要自己处理,手动添加alert即可

    NSMutableString * string = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"136****0000"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];

    swift代码:

  • 相关阅读:
    js参数自定义
    分页插件--记录
    .net mvc接收参数为null的解决方案
    c#枚举转字典或表格
    openlayers添加弹出框
    openlayers按坐标点播放
    openlayers轨迹匀速播放
    MyEclipse配置进行Hibernate逆映射
    BIO,NIO,AIO
    Git遇到的一点错误
  • 原文地址:https://www.cnblogs.com/KiVen2015/p/9209106.html
Copyright © 2011-2022 走看看