苹果开发,iOS开发,MacOS开发,Android开发,Windows开发iOS

iOS拨打电话的方法

2019-06-14  本文已影响0人  DockeriOS

方法一:直接拨打,不弹出提示,拨打完电话不回到原来的应用

/**
  * 拨打电话,不弹出提示,拨打完电话不回到原来的应用
  *
  * @param phoneNumber 电话号码字符串
 */
- (void)makePhoneCall:(NSString *)phoneNumber {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]];
}

方法二:弹出提示,拨打电话,拨打完后回到原来的应用

/**
  * 拨打电话,弹出提示,拨打完电话回到原来的应用
  *
  * @param phoneNumber 电话号码字符串
 */
- (void)makePhoneCall2:(NSString *)phoneNumber {
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]]];
    [self.view addSubview:callWebview];
}

方法三:弹出提示,拨打电话,拨打完后回到原来的应用(推荐这个!)

/**
  * 拨打电话,弹出提示,拨打完电话回到原来的应用
  * 注意这里是 telprompt://
  * @param phoneNumber 电话号码字符串
 */
- (void)makePhoneCall3:(NSString *)phoneNumber {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",phoneNumber]]];
}
上一篇下一篇

猜你喜欢

热点阅读