如何在应用程序内拨打电话或在通话结束后立即启动应用程序?我知道这是可能的,因为应用程序商店中的某些应用程序已经在执行此操作.
我从Apple网站获得了这个代码,它完美地工作:
-(IBAction) dialNumber:(id)sender{ NSString *aPhoneNo = [@"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ; NSURL *url= [NSURL URLWithString:aPhoneNo]; NSURL *url= [NSURL URLWithString:aPhoneNo]; NSString *osVersion = [[UIDevice currentDevice] systemVersion]; if ([osVersion floatValue] >= 3.1) { UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; [webview loadRequest:[NSURLRequest requestWithURL:url]]; webview.hidden = YES; // Assume we are in a view controller and have access to self.view [self.view addSubview:webview]; [webview release]; } else { // On 3.0 and below, dial as usual [[UIApplication sharedApplication] openURL: url]; } }