iOS 拨打电话的3种方法

iOS调用拨打电话的3种常用方法

1.使用系统调用,使用这种方法,拨打完电话不会回到原来的应用,还会停留在通讯录里,而且是直接拨打,不弹出提示

NSMutableString *str=[[NSMutableString alloc]  initWithFormat: @"tel:%@", @"177xxxx0000"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

2.创建UIWebView调用,使用这种方法,打完电话后还会回到原来的程序,也会弹出提示

NSMutableString * str=[[NSMutableString alloc] initWithFormat: @"tel:%@", @"177xxxx0000"];

UIWebView * webview = [[UIWebView alloc] init];

[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];

[self.view addSubview:webview]; 

3.使用系统调用,使用这种方法会回去到原来的程序里(注意这里的telprompt),也会弹出提示

NSMutableString * str=[[NSMutableString alloc] initWithFormat: @"telprompt://%@", @"177xxxx0000"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

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