ios-打电话

来源:互联网 发布:红警模型淘宝 编辑:程序博客网 时间:2024/04/30 00:00
ios 中实现打电话的功能是很简单的 我们可以使用两种方式实现打电话 但是我们有一点需要注意的是如果我们使用系统提供的那种打电话的方式会出现一种状况 电话播出之后 无法回到我们的应用界面 这个给出了解决方案 我们可以借助webView来只实现 打电话之后回到应用界面 请看下面代码:#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{#if 0    //方法一:    /*     缺点:不能返回当前应用     */    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:10086"]];#endif        /*     方法二:播打电话完成后会自动返回当前应用。拨打电话之前有提示。     */    //注意:不要设置webView大小    UIWebView *webView = [[UIWebView alloc] init];    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:10086"]]];    [self.view addSubview:webView];       }- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end

0 0
原创粉丝点击