Unhiding a view is very slow in CTCallCenter callEventHandler

帅比萌擦擦* 提交于 2019-11-29 00:05:52

Try changing your code to this:

- (void)ctCallStateDidChange:(NSNotification *)notification
{
   NSLog(@"121");
   NSString *callInfo = [[notification userInfo] objectForKey:@"callState"];
   if ([callInfo isEqualToString:CTCallStateDisconnected]) {
      NSLog(@"before show");
      [self.view viewWithTag:kNONEMERGENCYCALLSAVEDTOLOG_TAG].hidden = NO;
      NSLog(@"after show");
   }
}

Note:

  • The parameter is an NSNotification, not an NSDictionary
  • I would not compare strings with ==
  • No need to cast the view to change the hidden property
  • Use NO instead of false

Update: Got an idea: Could you try the following, please, in between the NSLogs?

dispatch_async(dispatch_get_main_queue(), ^{
   [self.view viewWithTag:kNONEMERGENCYCALLSAVEDTOLOG_TAG].hidden = NO;
});

Reading the CTCallCenter doc, it seems the callEventHandler is dispatched on "the default priority global dispatch queue", which is not the main queue where all the UI stuff happens.

kororo

Looks like there is no problem with your hidden code. If I were you, I would comment out all the code after the call ends, and uncomment them one by one to see what is the problem.

Hm... try to call [yourViewController.view setNeedsDisplay] after you change hidden property. Or avoid hidden, use alpha or addSubview: and removeFromSuperview methods instead.

djibouti33,

Where you put this sentence to listen when a user taps a button that dials a phone number?on WillResignActive function?

this sentence --> [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ctCallStateDidChange:) name:@"CTCallStateDidChange" object:nil];

Thanks for your time,

Willy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!