// 不能返回当前应用
NSString *str = [[NSStringalloc] initWithFormat:@"tel:%@",@"10086"];
// iOS 10.0之后
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:str]options:@{}completionHandler:nil];
// iOS 10.0 之前
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
// 拨打电话完成后会自动返回当前应用. 拨打电话之前有提示
NSString *str = [[NSStringalloc] initWithFormat:@"tel:%@",@"10086"];
UIWebView *callWebview = [[UIWebViewalloc] init];
[callWebview loadRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:str]]];
[self.viewaddSubview:callWebview];
本文介绍了在iOS应用中实现拨打电话功能的方法。包括了不同iOS版本间的差异处理,使用NSURL发起电话呼叫,并通过UIWebView来确保调用后能返回到应用内。
269

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



