以下代码可以正常工作以在iPhone 4s(运行iOS 5.1.1)中获取应用程序中的呼叫状态,但不能在iPhone 5s(运行iOS 7.1.2)中运行。可以帮助任何人吗?
在MyViewController.h中
@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");
}
}];
}