The permutation with a more concise and focused question after the initial question remained unanswered. Also adding a more detailed description of the problem after the next day of the study:
In my application delet ( didFinishLaunching ) I configured a callEventHandler to CTCallCenter . The idea is that when the callState state changes, I send a notification using the userInfo dict containing call.callState . In my opinion, I am watching this notification, and the userInfo dict contains the value CTCallDisconnected , I want to display the view.
The problem I am facing is that the invisible aspect takes, almost sequentially, ~ 7 seconds. Everything else works fine, and I know this because I have NSLog before and after opening, and these logs appear immediately, but the damned look is still 7 seconds behind.
Here is my code:
appDidFinishLaunching:
self.callCenter = [[CTCallCenter alloc] init]; self.callCenter.callEventHandler = ^(CTCall* call) {
Then I listen to this notification when the user presses a button dialing a phone number:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ctCallStateDidChange:) name:@"CTCallStateDidChange" object:nil];
Then in ctCallStateDidChange:
- (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"); } }
I traced the problem to the if condition in the above code example:
if ([[userInfo valueForKey:@"userInfo"] valueForKey:@"callState"] == CTCallStateDisconnected) {
If I just replace this:
if (1 == 1) {
Then the show will appear immediately!
The fact is that those NSLog statements are registered immediately, but the view is lagging behind it. How can this condition cause only part of its block to be executed immediately, and the rest wait ~ 7 seconds?
Thanks!