Ios rejects the controller and presents the controller with animation

I have a root view controller that represents an authentication controller. After user authentication, I need to reject the authentication controller and present the user controller (example: on-board power controller, regular user controller, professional user controller). What I would like to do is when the animated authentication controller is disabled, the corresponding controller is displayed (as if it was presented in front of the authentication controller).

These are the two solutions that I have tried so far. Both show the root view controller between transitions.

  • In the -viewDidAppearroot view controller, I represent the corresponding controller (authentication or user controller).

  • I tried firing and submitting two controllers using the following:

    [authenticationController dismissViewControllerAnimated:<NO|YES> completion:^{
        [userController presentViewController:viewController animated:animated completion:nil];
    }];
    

TL; DR:

I have a modal presentation hierarchy that starts like rootViewController->viewController1, and I want to go to rootViewController->viewController2where it viewController1animates down to showviewController2

+4
source share
3 answers

As soon as the user authenticates, set the flag of significant value for you, then say, as soon as they click OK or Submit, you can check and set the flag.

- , , , , VC .

, .

EDIT:

0

documentation -dismissViewControllerAnimated:completion: :

, , . , ; .

, :

Storyboard screenshots

vc2, . vc2 -viewWillAppear vc1, :

- (void)viewWillAppear {
    if (!userLoggedIn) {
        UIViewController *vc1 = [[YourViewControllerClass1 alloc] init];
        [self presentViewController:vc1  animated:YES completion:nil];
    }
}

Show Login VC vc1, :

- (IBAction)touchUpInsideShowLoginVCButton:(id)sender {
    UIViewController *loginVC = [[YourLoginViewControllerClass alloc] init];
    loginVC.delegate = self.presentingViewController;
    [self presentViewController:loginVC  animated:YES completion:nil];
}

vc2 loginVC , vc2 loginVC. ( delegate .h loginVC:)

@property (strong, nonatomic) UIViewController *delegate;

, Login, , ( -dismissViewControllerAnimated:completion: on vc2, ), vc2 .

- (IBAction)touchUpInsideLoginButton:(id)sender {
    // ... your login code
    if (loginSuccessful) {
        [self.delegate dismissViewControllerAnimated:YES completion:nil];
    }
}
0

I think that it presentViewControllerdoes not support inserting the viewController below the top represented by the ViewController, which is the authentication controller here. If you have a navigationController for the rootViewController, you can try pushViewController:animated:before disabling the authentication controller, and push animated may be NO;

0
source

All Articles