zoukankan      html  css  js  c++  java
  • iOS开发- 拨打电话总结

    关于iOS应用拨打电话, 我所知道的有3种办法, 详细例如以下:


    一。利用openURL(tel)

    特点: 直接拨打, 不弹出提示。 而且, 拨打完以后, 留在通讯录中, 不返回到原来的应用。

    //拨打电话
    - (void)callPhone:(NSString *)phoneNumber
    {
        //phoneNumber = "18369......"
        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phoneNumber];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }

    二。利用requestWithURL (推荐使用)

    特点: 拨打前弹出提示。 而且, 拨打完以后会回到原来的应用。

    //拨打电话
    - (void)callPhone:(NSString *)phoneNumber
    {
        //phoneNumber = "18369......"
        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phoneNumber];
        UIWebView * callWebview = [[UIWebView alloc] init];
        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
        [self.view addSubview:callWebview];
    }

    三。利用openURL(telprompt)

    特点: 拨打前弹出提示。 而且, 拨打完以后会回到原来的应用。

    注意: Apple的官方文档中, 没有出现过telprompt, 之前也有人使用这个, 上传审核的时候被拒绝了。

    //拨打电话
    - (void)callPhone:(NSString *)phoneNumber
    {
        //phoneNumber = "18369......"
        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",phoneNumber];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }



  • 相关阅读:
    组合模式
    MySQL8.0 下载安装启动(Windows10)
    OI如逆旅,我亦是行人——省选
    闲话—江湖痴情浅,信步余生。平剑红烛,青丝微绾,却话奁中。
    此时彼方
    CSP 2019游记 & 退役记
    西狂 杨过
    SDOI 2019 Round1 游记
    NOIP2018游记
    未来可期,不知所终
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4196555.html
Copyright © 2011-2022 走看看