2012-12-06 71 views
1

可能重複:
How to find out if user pressed call or cancel button when making call from my app?IOS:如何檢測用戶取消撥打電話號碼

我可以撥入使用IOS電話號碼下面的代碼:

NSURL *url = [NSURL URLWithString:@"tel://123"]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; 
[webView loadRequest:request]; 

因爲將顯示一個警報視圖運行此代碼後,我怎麼能檢測用戶是否按下取消按鈕或呼叫按鈕?

回答

1

如果不越獄您的設備,這是不可能的。但是,正如@J Shapiro在this post中所建議的那樣,您可以使用以下代碼來偵聽UIApplicationSuspendedNotification通知。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:@"UIApplicationSuspendedNotification" object:nil]; 

-(void)suspended:(NSNotification *) notification 
{ 
    NSLog(@"Suspended"); 
} 
+0

這似乎不適用於iOS8,任何已知的替代? – BaSha