ios 打电话结束返回到应用中

在我们做打电话这个功能时,我们常常是调用这个方法:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://xxxxx"]];


然而,这样实现了功能后,结束通话后,确不能回到自己的应用中来。最近在网上搜了很多,苹果自己是没有提供回调函数的。强大的网友们通过用 UIWebView这个控件实现了这个方法。

代码如下:

- (void) dialPhoneNumber:(NSString *)aPhoneNumber  
{  
    NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",aPhoneNumber]];  
    if ( !phoneCallWebView ) {          
        phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];  
    }  
    [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];  
}  
- (void) dealloc  
{  
    // cleanup  
    [phoneCallWebView release], phoneCallWebView = nil;  
   [super dealloc];  
}  


还有一种不能上传到appstore上的方法。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://xxxx"]];  


也就是将tel改为了telprompt


 

大家可以尝试下。




原文地址:https://www.cnblogs.com/pangblog/p/3260658.html