简体   繁体   English

通话后加载应用

[英]Loading app after phone call

I am currently trying to make a speed dial app for various numbers the user might enter. 我目前正在尝试为用户可能输入的各种号码制作一个快速拨号应用程序。 I am loading the phone all like so after clicking a UITableViewCell 单击UITableViewCell后,我像这样加载手机

- (IBAction)Dialer:(id)sender{
    NSURL *url = [ [ NSURL alloc ] initWithString: @"tel:09-410-7078" ];
    [[UIApplication sharedApplication] openURL:url];
}

that loads up the phone dialer and dials the number.. I'm woundering if after the phone call has ended is its possible to load the app from where it exited for the phone call.. or if there is a better way to do what I am trying to do? 加载电话拨号程序并拨打电话号码。.如果在电话结束后是否有可能从退出电话的地方加载应用程序,或者是否有更好的方法来做,那我就很痛苦我想做什么?

From iOS 5.0 onwards, we return to the app after the call ends. 从iOS 5.0开始,通话结束后我们将返回该应用程序。 Find the below code. 查找以下代码。

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

Actually you should keep in mind that an application can be unloaded at any moment. 实际上,您应该记住,可以随时卸载应用程序。 But when your application is being unloaded your app delegate gets some messages ( applicationWillTerminate , applicationWillResignActive , applicationDidEnterBackground ). 但是,当您的应用程序被卸载时,您的应用程序代理会收到一些消息( applicationWillTerminateapplicationWillResignActiveapplicationDidEnterBackground )。 You should read this post . 您应该阅读这篇文章 In those methods you should save some parameters of your application (current page, settings, etc.) and use them when your application is launched or become active again. 在这些方法中,您应该保存应用程序的某些参数(当前页面,设置等),并在应用程序启动或再次激活时使用它们。

If you want to start your application manually you shouldn't do so. 如果要手动启动应用程序,则不应这样做。 User will be surprised by such behavior. 用户会对这种行为感到惊讶。

I searched very long time and got this code from Apple site and it works perfectly: 我搜索了很长时间,并从Apple网站获得了此代码,它可以完美地运行:

-(IBAction) dialNumber:(id)sender{

NSString *aPhoneNo = [@"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ; 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];
}


}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM