【问题标题】:CTCallState event handler not getting called if no breakpoint is set如果没有设置断点,则不会调用 CTCallState 事件处理程序
【发布时间】:2013-01-04 23:31:28
【问题描述】:

我遇到了有史以来最奇怪的错误,我正在我的 iPhone 上运行该应用程序,并且我有以下代码:

self.callCenter = [[CTCallCenter alloc] init];
    [self.callCenter setCallEventHandler: ^(CTCall* call) {
        if ([call.callState isEqualToString: CTCallStateDisconnected]) {
            NSLog(@"call ended");
            dispatch_sync(dispatch_get_main_queue(), ^(void) {
                NSLog(@"on main thread!");
                NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
                [userInfo setValue:weakSelf.recordRef forKey:kContactKey];
                [[NSNotificationCenter defaultCenter] postNotificationName:kCallEndedNotification object:nil userInfo:userInfo];
            });
        }
    }];

由于某种原因,这段代码没有被调用。但是如果我在 if 语句上放了一个断点,它就会被调用。知道为什么会发生这种情况吗?

【问题讨论】:

    标签: iphone objective-c ios ipad


    【解决方案1】:

    我相信这是 iOS SKD 6 的错误。因为事件“CTCallStateDisconnected”应该在你的应用程序处于后台时被调用,所以它根本不会被调用。我认为,为什么将断点放在那里就可以了,原因是因为调用事件的时间。如果它在断点处停止,则调用仍在进行,并且当您的应用处于前台时调用事件。

    看这里,在 iOS5 中这是有效的: setCallEventHandler test

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多