http://blog.csdn.net/ouy_huan/article/details/30506925 借鑒于此,謝謝
1程拭、這種方法定踱,打完電話后還會(huì)回到原來的程序,也會(huì)彈出提示恃鞋,推薦這種
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"182xxxxxxxx"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
2崖媚、這種方法,掛斷電話會(huì)在原來的應(yīng)用恤浪,而且是直接撥打畅哑,不彈出提示
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@", @"電話號(hào)碼"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
此方法可以自己定義提示信息:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"撥打該電話按照正常資費(fèi)由運(yùn)營商收取:%@", @"182xxxxxxxx"] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[alert dismissViewControllerAnimated:YES completion:^{
NSLog(@"取消撥打電話");
}];
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@", @"182xxxxxxxx"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}];
[alert addAction:action1];
[alert addAction:action2];
[self presentViewController:alert animated:YES completion:^{
NSLog(@"彈出撥打電話號(hào)碼彈框");
}];
3,這種方法也會(huì)回去到原來的程序里(注意這里的telprompt)水由,也會(huì)彈出提示
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@", @"182xxxxxxxx"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];