更改关键窗口不会调用视图将/已显示/显示

时间:2018-01-03 10:19:49

标签: ios uiviewcontroller uiwindow viewwillappear viewdiddisappear

当我更改关键窗口时,rootViewController(s)没有接收到的视图将/确实出现/消失。

    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];
                    }];

更新 手动调用 - beginAppearanceTransition:animated: - endAppearanceTransition 来自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 个答案:

没有答案