美文网首页
iOS开发中拨打电话的方法

iOS开发中拨打电话的方法

作者: 多啦A梦的百宝袋 | 来源:发表于2016-09-30 13:33 被阅读94次

    1,这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示

    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
        //            NSLog(@"str======%@",str);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
        ````
    2,创建一个UIWebView来加载URL,拨完后能自动回到原应用(推荐)
    

    UIWebView *webView = [[UIWebView alloc]init];
    NSMutableString *str = [[NSMutableString alloc]initWithFormat:@"telprompt://%@",_serviceModel.phone];
    NSURL *url = [NSURL URLWithString:str];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    [self.view addSubview:webView];

    3,这种方法也会回去到原来的程序里(注意这里的telprompt),也会弹出提示。
    私有API,因此可能通不过苹果官方审核。
    

    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"186xxxx6979"];
    // NSLog(@"str======%@",str);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]

    相关文章

      网友评论

          本文标题:iOS开发中拨打电话的方法

          本文链接:https://www.haomeiwen.com/subject/wnnlyttx.html