iOS项目中调用拨号程序的三个方法

1、openURL,利用Application的openURL方法实现,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示

1
2
3
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@", @"187xxxx7135"];
 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

2、UIWebView,利用WebView请求RUL来实现,打完电话后还会回到原来的程序,也会弹出提示,推荐这种

1
2
3
4
5
6
7
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@", @"187xxxx7135"];
 
    UIWebView * callWebview = [[UIWebView alloc] init];
 
    [self.window addSubView:callWebvew];
 
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];

3、openURL,第一种方式类似,这种方法也会回去到原来的程序里(注意这里的telprompt),也会弹出提示

1
2
3
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@", @"187xxxx7135"];
 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]

Leave a Reply