NSURL* url = [[NSURL alloc] initWithString:@“http://blog.csdn.net/iukey”];

[[ UIApplication sharedApplication]openURL:url];

NSURL* url = [[NSURL alloc] initWithString:@“tel:110”];
[[ UIApplication sharedApplication]openURL:url];

ios 调用打电话 三种方式

// 第一种方式打电话
[html] view plaincopy

-(void)makeACall{
NSString *number = @“”;// 此处读入电话号码
NSString *num = [[NSString alloc] initWithFormat:@“tel://%@”,number]; //number为号码字符串 如果使用这个方法 结束电话之后会进入联系人列表
}
// 第二种方式打电话 [html] view plaincopy

-(void)makeACall{
NSString *num = [[NSString alloc] initWithFormat:@“telprompt://%@”,number]; //而这个方法则打电话前先弹框 是否打电话 然后打完电话之后回到程序中 网上说这个方法可能不合法 无法通过审核
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //拨号
}
// 第三种方式打电话 // 下面的代码能在应用中添加一个电话按钮,用UIWebView加载电话,这种是合法的,可以上App Store的。 [html] view plaincopy -(void)makeACall{
NSString *phoneNum = @“”;// 电话号码
NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@“tel:%@”,phoneNum]];
if ( !phoneCallWebView ) {
phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];// 这个webView只是一个后台的View 不需要add到页面上来 效果跟方法二一样 但是这个方法是合法的
}
[phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
}

posted on 2015-04-14 14:55  韩江河  阅读(190)  评论(0编辑  收藏  举报