iOS打电话功能

2015-09-06 0 143
iOS打电话功能

//第一种打电话的方式

– (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];//也可以不加到页面上

}


遇见资源网 objective-c iOS打电话功能 http://www.ox520.com/18055.html

上一篇: 获取window上的view
下一篇: OC之C语言基础
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务