Unhiding a view is very slow in CTCallCenter callEventHandler

后端 未结 4 1320
别那么骄傲
别那么骄傲 2020-12-15 12:25

Reposting with more concise and focused question after original question went unanswered. Also adding more insight into the problem after another day of research:

I

相关标签:
4条回答
  • 2020-12-15 12:48

    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.

    0 讨论(0)
  • 2020-12-15 12:51

    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.

    0 讨论(0)
  • 2020-12-15 12:55

    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.

    0 讨论(0)
  • 2020-12-15 12:59

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

    0 讨论(0)
提交回复
热议问题