iOS打电话功能 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    //第一种打电话的方式

    - (IBAction)firstCall:(id)sender {

    NSString *phone = @"18749627117";

    if (phone != nil) {

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phone]]];//使用这个方法,打电话结束后会进入联系人列表

    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",phone]]];//使用这种方法在拨打电话前会先弹出框,询问是否打电话,然后打完电话之后回到主程序中,有人说这种方法可能不合法,无法通过审核

    }

    }

    //第二种打电话的方式

    - (IBAction)secondCall:(id)sender {

    NSString *str = [NSString stringWithFormat:@"tel:%@",@"18749627117"];

    UIWebView *callWebView = [[UIWebView alloc]init];

    [callWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];

    [self.view addSubview:callWebView];//也可以不加到页面上

    }

最新文章