iOS 之拨打电话的方法


- (IBAction)didClickCall:(id)sender {
    // 可能审核被拒
    //NSString *phoneNumber = [NSString stringWithFormat:@"telprompt://%@", @"4006666536"];
    
    // 直接拨打电话,不弹出提示框
    NSString *phoneNumber = [NSString stringWithFormat:@"tel:%@", @"4006666536"];
    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];

    //
    UIWebView *callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:phoneNumber]]];
    [self.view addSubview:callWebview];
}


    @objc func didClickCall() {
        let courierPhone = "4006666536"
        
        // 可能审核被拒
        //let phoneNumber = "telprompt://\(courierPhone)"
        
        // 直接拨打电话,不弹出提示框
        let phoneNumber = "tel:\(courierPhone)"
        //UIApplication.shared.openURL(URL(string: phoneNumber)!)
        
        //
        let callWebview = UIWebView()
        callWebview.loadRequest(URLRequest(url: URL(string: phoneNumber)!))
        addSubview(callWebview)
    }


你可能感兴趣的:(iOS 之拨打电话的方法)