iOS 开发 关于应用中使用拨打电话那点事

时间:2014-08-01 18:37:22   收藏:0   阅读:429

 

一、利用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];
}

iOS 开发 关于应用中使用拨打电话那点事,布布扣,bubuko.com

原文:http://www.cnblogs.com/allenChan/p/3885131.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!