呼叫中心块在ios中只执行一次

时间:2014-06-20 10:11:14

标签: ios iphone phone-call

NSURL *telURL = [NSURL URLWithString:[@"tel://" stringByAppendingString:@"9723539389"]];
_PhoneCallWebView = [[UIWebView alloc] init];
[_PhoneCallWebView loadRequest:[NSURLRequest requestWithURL:telURL]];

AppDelegate *appDel =(AppDelegate*)[UIApplication sharedApplication].delegate;

appDel.callCenter =  [[CTCallCenter alloc] init];
[appDel.callCenter setCallEventHandler:^(CTCall* call)
{
    if ([call.callState isEqualToString: CTCallStateConnected])
    {
        NSLog(@"Connected");
        [[NSUserDefaults standardUserDefaults] setInteger:2 forKey:@"Connected"];
    }
    if ([call.callState isEqualToString: CTCallStateDialing])
    {
        NSLog(@"Dialing");
        [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"Dialing"];
    }
    if ([call.callState isEqualToString: CTCallStateDisconnected])
    {   
        NSLog(@"Disconnected");
        [[NSUserDefaults standardUserDefaults] setInteger:3 forKey:@"Disconnected"];
    }
    if ([call.callState isEqualToString: CTCallStateIncoming])
    {          
        NSLog(@"Incoming");
    }
    else
    {
        NSLog(@"Nothing");
    }
}];

上面的代码控制仅在拨号时进入阻止状态。但之后,从未在连接或断开连接时执行该块。

0 个答案:

没有答案