我正在尝试从我的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发起呼叫......
答案 0 :(得分:18)
这是我的代码:
NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"];
[[UIApplication sharedApplication] openURL:url];
使用此选项,以便在通话结束后它将返回应用程序。
答案 1 :(得分:1)
UIWebView *callWebview = [[UIWebView alloc] init];
NSURL *telURL = [NSURL URLWithString:@"tel:+9196815*****"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
请尝试这一点,一定会让你回到你的应用程序。
答案 2 :(得分:0)
以下代码将不会返回到您的应用[在通话前不会显示提醒视图]
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]];
答案 3 :(得分:0)
NSString *phoneNumber = // dynamically assigned
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
[[UIApplication sharedApplication] openURL:phoneURL];
答案 4 :(得分:-1)
你也可以使用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];
答案 5 :(得分:-3)
请查看OneTap应用。这是免费的 它就是这样做的。
答案 6 :(得分:-4)
结束通话后无法返回应用程序,因为它是一个应用程序。