美文网首页A知识点2iOS Developer
iOS 拨打电话-三种不同的方法实现

iOS 拨打电话-三种不同的方法实现

作者: iOS_愛OS | 来源:发表于2016-10-10 15:21 被阅读340次
    • 一.点击即拨打,不会提示用户是否拨打。相当于点击了拨打键

    貌似有的系统调用了这个方法打完电话后,会停留在通话记录里。
    iOS10 亲测,打完打完电话会回到原来的程序

                    NSString *phoneNumber = [NSString stringWithFormat:@"telprompt://%@",@"13377892977"];
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
    
    
    • 二. 利用WebView的方法来打电话

    弹出提示,打完回到原程序

    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
        UIWebView * callWebview = [[UIWebView alloc] init];
        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
        [self.view addSubview:callWebview];
    
    • 三.[[UIApplication sharedApplication] openURL:]

    弹出提示,打完回到原程序

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

    相关文章

      网友评论

      本文标题:iOS 拨打电话-三种不同的方法实现

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