在iOS中使用CTCallCenter检测呼叫状态
以下代码可以很好地在iPhone 4s(运行iOS 5.1.1)中获取我的应用程序中的呼叫状态,但在iPhone 5s(运行iOS 7.1.2)中无法获取wokring。你能帮助任何人吗 在MyViewController.h中在iOS中使用CTCallCenter检测呼叫状态,ios,objective-c,iphone,Ios,Objective C,Iphone,以下代码可以很好地在iPhone 4s(运行iOS 5.1.1)中获取我的应用程序中的呼叫状态,但在iPhone 5s(运行iOS 7.1.2)中无法获取wokring。你能帮助任何人吗 在MyViewController.h中 @property (nonatomic, strong) CTCallCenter* callCenter; 在MyViewController.m中 - (void)viewDidLoad { [self registerForCalls]; } - (
@property (nonatomic, strong) CTCallCenter* callCenter;
在MyViewController.m中
- (void)viewDidLoad
{
[self registerForCalls];
}
- (void) registerForCalls {
self.callCenter = [[CTCallCenter alloc] init];
[callCenter setCallEventHandler: ^(CTCall* call) {
if (call.callState == CTCallStateDisconnected)
{
NSLog(@"Call has been disconnected");
}
else if (call.callState == CTCallStateConnected)
{
NSLog(@"Call has just been connected");
}
else if (call.callState == CTCallStateIncoming)
{
NSLog(@"Call is incoming");
}
else if (call.callState == CTCallStateDialing)
{
NSLog(@"Call is Dialing");
}
else
{
NSLog(@"None of the conditions");
}
}];
}
也许你可以试试这个解决方案