基本上,我有以下两种方法推送同一个调用视图控制器_vcCall。 pushViewController在on_calling方法下运行正常,但是在on_incoming_call下无效。我确信self.navigationController不是null,_vcCall也不是null。我在两种方法中都打印出了navigationController和_vcCall,它们都具有相同的地址。我甚至试图在on_incoming_call中创建一个新的viewcontroller,但它仍然无法正常工作。
我在屏幕上只有一个按钮,当它被点击时它会推送到呼叫视图控制器。当触发on_calling方法时,它会成功推送到_vcCall,但是当触发on_incoming_call时,它什么都不做,但阻止我点击“呼叫”按钮。看起来在当前视图控制器上有一个透明页面。
有人可以帮忙吗?
- (void)viewDidLoad {
_vcCall = [[CallViewController alloc] init];
}
- (void) sipConnection: (SIPConnection *) connection on_calling: (NSDictionary *) userInfo {
NSLog(@"on_calling: navi: %@", self.navigationController);
[self.navigationController pushViewController:_vcCall animated:YES];
}
- (void)sipConnection:(SIPConnection *)connection on_incoming_call:(NSDictionary *)userInfo {
NSLog(@"on_incoming_call: navi: %@", self.navigationController);
[self.navigationController pushViewController:_vcCall animated:YES];
}
这是首次触发on_calling时控制台中的输出
on_calling: navi: <navViewController: 0x77779d0>
on_incoming_call: navi: <navViewController: 0x77779d0>
以下部分是委托方法的名称
- (void) processCallMediaState: (NSDictionary *) userInfo {
int state = [[userInfo objectForKey: kState] intValue];
switch(state) {
case PJSIP_INV_STATE_CALLING: { // After INVITE is sent.
[self.delegate sipConnection:self on_calling:userInfo];
break;
}
case PJSIP_INV_STATE_INCOMING: {// After INVITE is received.
[self.delegate sipConnection:self on_incoming_call:userInfo];
break;
}
case PJSIP_INV_STATE_EARLY: {// After response with To tag.
break;
}
case PJSIP_INV_STATE_CONNECTING:{ // After 2xx is sent/received.
break;
}
case PJSIP_INV_STATE_CONFIRMED: { // After ACK is sent/received.
[self.delegate sipConnection:self on_respond:userInfo];
break;
}
case PJSIP_INV_STATE_DISCONNECTED: {
[self.delegate sipConnection:self on_ending:userInfo];
break;
}
}
}
答案 0 :(得分:3)
检查代码是否未在后台线程上调用,因为必须在主线程上运行与UI有关的任何内容。
我不确定但是在视图控制器的同一个实例上调用push可能是罪魁祸首。每次推动时尝试设置一个新实例,而不是在ViewDidLoad方法中执行它。