Define - viewWillAppear comes from opening the app or deselecting the modal

I am currently loading application load data on the start screen. This is happening in my WillAppear view. I also have a modal that appears on this screen, and when closed, it does the same logic that loads the data into viewWillAppear.

How do I load data only when the application is opened and not when the modal is closed?

+3


source to share


1 answer


UIViewController

provides methods to determine this:



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

    if ([self isBeingPresented] || [self isMovingToParentViewController]) {
        // being presented or pushed
    } else {
        // showing again because another VC was dismissed
    }
}

      

+5


source







All Articles