Why is viewDidAppear in a UITabBarController executed before a view?

I have a UITabBarController that is nested in a UIView-Subclass (ImageViewer) as a third tab.

In this subclass of ImageViewer, I call the method viewDidAppear:

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    /* ... start custom code ... 
    NSLog(@"viewDidAppear tag 1 passed);          /* BREAKPOINT 1 here

    [myUIActivityIndicator stopAnimating];

    NSLog(@"viewDidAppear tag 2 passed);          /* BREAKPOINT 2 here
    /* ... end custom code ... 
}

the method is called automatically, but, strangely enough, the view appears only after this method is fully processed?

When I set breakpoints (1 and 2) as indicated, processing (when selecting a tab) stops while the previous tab is still displayed. Only when you click Continue after the second breakpoint will the view be displayed. (FYI NSLogs run silently).

In this case, it viewDidAppearbehaves more like viewWillAppear....

Any clues what might happen?

Greetings

+3
2

, -viewDidAppear:, performSelector:withObject:afterDelay: :

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self performSelector:@selector(updateUI) withObject:nil afterDelay:0.0];
}


- (void)updateUI
{
    // Do your UI stuff here
}

, , UIKit . updateUI . , , , .

+11

, , , , " " viewDidAppear. viewDidAppear.

, , . :

[self otherCode];

:

[NSTimer scheduledTimerWithTimeInterval:.5 
    target:self 
    selector:@selector(otherCode) 
    userInfo:nil 
    repeats:NO];

" " .

+1

Source: https://habr.com/ru/post/1777303/


All Articles