Reject the view and submit a new inside applicationDidEnterBackground

I have an application that presents its own password entry when the user either launches the application or reopens it from the background. When the user opens it from the background, there should not be a “flash” of the real application, in other words, the security screen must be fully loaded before the user opens the application again.

I have this setting great for most screens.

In one scenario, a user can rotate an application that calls segue from a tab bar controller into a horizontal view controller. In this case, I have a problem. If I did not pull out the rotating screen, the input screen will appear horizontally, even if the user reopens the application in the portrait.

If I fire him with animation, then the lock screen will not start loading until the application restarts, so you get flash content.

If I turn it off without animation, the lock screen will still be displayed horizontally.

Here is what is called from applicationDidEnterBackground:

    TabBarController *tbc = (TabBarController*)self.window.rootViewController;        

    void (^openPasscode)() = ^void() {
        KVPasscodeViewController *passcodeController = [[KVPasscodeViewController alloc] init];
        passcodeController.delegate = self;
        UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeController];

        // Change animated to YES and the new view isn't loaded until after the app restarts
        [self.window.rootViewController presentViewController:passcodeNavigationController animated:NO completion:nil];

    };

    if (tbc.isShowingLandscapeView) {
        [self.window.rootViewController dismissViewControllerAnimated:NO completion:openPasscode];
    } else {
        openPasscode();
    }
+3
source share
3 answers

UINavigationController, ( UIViewController.h):

- (BOOL)shouldAutorotate {
    return YES; // when app launched while device in landscape. it needs to rotate to portrait.
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (UIInterfaceOrientationPortrait == interfaceOrientation);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
+1

... applicationDidEnterBackground , , , ( - , , ).

, , , , . applicationDidEnterBackground:

[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate date]];

- , , .

+1

What happens if you submit your kind of access code in applicationWillEnterForegroundinstead applicationDidEnterBackground?

I think that when the application resumes, it will present your screen lock screen controller before the main screen of the application appears - this will avoid any “flash” of the main view, and any changes in the rotation will be developed before the presentation appears.

0
source

All Articles