可能重复:
How to find out if user pressed call or cancel button when making call from my app?
我可以使用以下代码拨打ios中的电话号码:
NSURL *url = [NSURL URLWithString:@"tel://123"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[webView loadRequest:request];
因为在运行此代码后会显示警报视图,如何检测用户是否按下“取消”按钮或“呼叫”按钮?
答案 0 :(得分:1)
如果没有越狱设备,这是不可能的。但是,正如@J Shapiro在this post中所建议的那样,您可以使用以下代码来收听UIApplicationSuspendedNotification
通知。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:@"UIApplicationSuspendedNotification" object:nil];
-(void)suspended:(NSNotification *) notification
{
NSLog(@"Suspended");
}