Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中使用CTCallCenter检测呼叫状态_Ios_Objective C_Iphone - Fatal编程技术网

在iOS中使用CTCallCenter检测呼叫状态

在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]; } - (

以下代码可以很好地在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];
}

- (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");
        }
    }];
}

也许你可以试试这个解决方案