【发布时间】:2012-03-28 16:30:22
【问题描述】:
我使用此代码从我的应用程序拨打电话(我使用 webview,因为通话结束后,我不想显示拨号器应用程序):
UIWebView *callWebview = [[UIWebView alloc] init];
[self.view addSubview:callWebview];
NSURL *telURL = [NSURL URLWithString:tel];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
我通过订阅通知检测到通话结束:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ctCallStateDidChange1:) name:@"CTCallStateDidChange" object:nil];
- (void)ctCallStateDidChange1:(NSNotification *)notification
{
NSString *call = [[notification userInfo] objectForKey:@"callState"];
if ([call isEqualToString:CTCallStateDisconnected])
{
NSLog(@"Call has been disconnected");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Obvestilo" message:@"Some text?"
delegate:self cancelButtonTitle:@"Yes" otherButtonTitles: @"No", nil];
[alert show];
}
}
}
我需要在通话结束后显示 alertview 并将控制权返回给我的应用程序,但有时需要一些时间才能检测到通话结束并发出通知,并且我的应用程序在此期间保持无响应。
你有什么想法吗?
【问题讨论】:
标签: iphone objective-c uiwebview nsnotifications