我知道如何在iPhone中以编程方式直接从我的应用程序拨打电话,但是在调用呼叫之前,我的应用程序正在终止,一旦呼叫退出,我的应用程序必须恢复。如何以编程方式为iPhone执行此操作?
谢谢。
答案 0 :(得分:1)
请参阅此主题,您可以从那里获取代码片段并使用它 making a phone call w/o quitting an appication
请记住,只有iOS 3.1才有可能。如果您定位iOS 3.0,则无法退出该应用程序。
NSString *callString = [NSString stringWithFormat:@"tel:%@", @"412-33-44-55"];
NSURL *url= [NSURL URLWithString:callString];
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
if ([osVersion compare: @"3.1" options: NSNumericSearch] >= NSOrderedSame ) {
UIWebView *webview = [[UIWebView alloc] initWithFrame:[callButton frame]];
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:callButton];
[webview release];
}
else {
// On 3.0 and below, dial as usual
NSString * s = [NSString stringWithFormat:@"tel://%@",@"412-33-44-55"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:s]];
}