#pragma mark -- 拨打电话
- (void)call:(UIButton *)button {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"您确定要拨打该号码吗?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSString *phoneNum = [NSString stringWithFormat:@"tel://%@",self.result[@"data"][@"telephone"]];
NSLog(@"%@",phoneNum);
NSURL *phoneURL = [NSURL URLWithString:phoneNum];
//web可返回应用
if (!self.callWebView) {
self.callWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
}
[self.callWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
//调出拨号界面
[[UIApplication sharedApplication] openURL:phoneURL];
}];
[alert addAction:action1];
[alert addAction:action2];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)call:(UIButton *)button {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"您确定要拨打该号码吗?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSString *phoneNum = [NSString stringWithFormat:@"tel://%@",self.result[@"data"][@"telephone"]];
NSLog(@"%@",phoneNum);
NSURL *phoneURL = [NSURL URLWithString:phoneNum];
//web可返回应用
if (!self.callWebView) {
self.callWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
}
[self.callWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
//调出拨号界面
[[UIApplication sharedApplication] openURL:phoneURL];
}];
[alert addAction:action1];
[alert addAction:action2];
[self presentViewController:alert animated:YES completion:nil];
}