从iPhone应用程序进行编程,结束通话后返回到应用程序

我试图从我的iPhone应用程序发起一个电话,我做了以下的事情..

-(IBAction) call:(id)sender { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Call Besito" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit", nil]; [alert show]; [alert release]; } - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex != [alertView cancelButtonIndex]) { NSString *phone_number = @"0911234567"; // assing dynamically from your code [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phone_number]]]; NSString *phone_number = @"09008934848"; NSString *phoneStr = [[NSString alloc] initWithFormat:@"tel:%@",phone_number]; NSURL *phoneURL = [[NSURL alloc] initWithString:phoneStr]; [[UIApplication sharedApplication] openURL:phoneURL]; [phoneURL release]; [phoneStr release]; } } 

通过上面的代码.. 我能够成功打个电话 .. 但是当我结束了一个电话,我不能够返回到我的应用程序

所以,我想知道如何实现,那么…请告诉我如何使用webview发起呼叫…

感谢和关心Ranjit

这是我的代码:

 NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"]; [[UIApplication sharedApplication] openURL:url]; 

使用这个,这样,通话结束后,它将返回到应用程序。

 UIWebView *callWebview = [[UIWebView alloc] init]; NSURL *telURL = [NSURL URLWithString:@"tel:+9196815*****"]; [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 

请尝试这一点,一定会让你回到你的应用程序。

 NSString *phoneNumber = // dynamically assigned NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber]; NSURL *phoneURL = [NSURL URLWithString:phoneURLString]; [[UIApplication sharedApplication] openURL:phoneURL]; 

以下代码将不会返回到您的应用程序[调用之前不会显示任何alertview]

 UIWebView *callWebview = [[UIWebView alloc] init]; NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]]; [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 

以下代码将返回到您的应用程序“alertview将显示在拨打电话之前”

 UIWebView *callWebview = [[UIWebView alloc] init]; NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", phoneNumber]]; [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 

你也可以使用webview,这是我的代码:

 NSURL *url = [NSURL URLWithString:@"tel://123-4567-890"]; UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 150, 100)]; [self.view addSubview:btn]; UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(50, 50, 150, 100)]; webview.alpha = 0.0; [webview loadRequest:[NSURLRequest requestWithURL:url]]; // Assume we are in a view controller and have access to self.view [self.view insertSubview:webview belowSubview:btn]; [webview release]; [btn release]; 

请看一下OneTap应用程序。 它是免费的它就是这样做的。

结束通话后无法返回到应用程序,因为它是一个应用程序。