第一种方式
NSString *phone = @“88888888”
if (phone != nil) {
NSString *telUrl = [NSString stringWithFormat:@"telprompt:%@",phone];
NSURL *url = [[NSURL alloc] initWithString:telUrl];
[[UIApplication sharedApplication] openURL:url];
}
第二种方式
UIWebView*callWebview =[[UIWebView alloc] init];
NSString *telUrl = [NSString stringWithFormat:@"tel:%@",phone];
NSURL *telURL =[NSURL URLWithString:telUrl];// 貌似tel:// 或者 tel: 都行
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
//记得添加到view上
[self.view addSubview:callWebview];
本文介绍了在iOS应用中实现电话拨打功能的两种方法:一种是通过直接使用URL Scheme进行拨号,另一种则是利用UIWebView加载tel URL的方式。这两种方法各有特点,能够满足不同场景下拨打需求。
932

被折叠的 条评论
为什么被折叠?



