Changing the key window does not call view will/did dis/appear

353 Views Asked by At

When I change the key window, the rootViewController(s) do not receive view will/did appear/disappear.

    SplashViewController *screenLockViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
    [self.splashWindow.rootViewController presentViewController:splashViewController animated:NO completion:nil];

    [self.splashWindow makeKeyWindow];

    __weak typeof(self) welf = self;
    [UIView transitionWithView:self.window
                      duration:0.25
                       options:UIViewAnimationOptionTransitionNone
                    animations:^{
                        welf.window.alpha = 0.0f;
                    } completion:^(BOOL finished) {
                        [welf.window setHidden:YES];
                    }];

Update: Manually called – beginAppearanceTransition:animated: and – endAppearanceTransition from https://stackoverflow.com/a/25033107/2287841

    SplashViewController *screenLockViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
    [self.splashWindow.rootViewController presentViewController:splashViewController animated:NO completion:nil];

    [self.window.rootViewController beginAppearanceTransition:NO animated:shouldAnimate]; // call view will disappear
    [self.splashWindow makeKeyWindow];

    __weak typeof(self) welf = self;
    [UIView transitionWithView:self.window
                      duration:0.25
                       options:UIViewAnimationOptionTransitionNone
                    animations:^{
                        welf.window.alpha = 0.0f;
                        [welf.window.rootViewController endAppearanceTransition]; // call view did disappear
                    } completion:^(BOOL finished) {
                        [welf.window setHidden:YES];
                    }];
0

There are 0 best solutions below