iOS里面在程序里面实现拨打电话的方式,略知以下三种方法:
ps:其实仔细看起来没什么特殊的,但要特殊注意代码里面的关键词(下面用红色标出以作区别)
1、此方法,拨打完电话但是回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示
NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"131xxxx12345"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
2、此方法,打完电话后还会回到原来的程序,也会弹出提示(强烈推荐此方法)
NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"131xxxx12345"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
3、此方法也会回去到原来的程序里,会弹出提示
NSMutableString * phoneStr=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"182xxxx12345"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];