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]];
    }



  • 相关阅读:
    C# 利用 Geckofx60 实现下载
    C# 线程 线程池
    C# DateTime 与 String 格式转换
    C# WPF 获取程序路径
    C# 计时器 Timer 介绍
    获取远程图片并把它保存到本地
    php sql 过滤
    PHP如何生成伪静态
    用php获取客户端IP地址的方法
    php过滤危险html代码
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4196555.html
Copyright © 2011-2022 走看看