dizza213
dizza213

Reputation: 147

Flip view controllers inside bigger view controller will flip the main view controller

I want to flip a view controller which has smaller size than the screen. I am using transitionFromViewController but this would flip also the whole screen. And I want just the smaller view controller to be flipped.

First the login should be visible, after flipped the register view should be available!

My code is

- (void)showLogin {
    vcLogin = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    [self.view addSubview:vcLogin.view];
    [self addChildViewController:vcLogin];

    if (IS_IPAD()) {
        vcLogin.view.center = self.view.center;
    }
}

- (void)showRegister {
    vcRegister = [[RegisterViewController alloc] initWithNibName:@"RegisterViewController" bundle:nil];
    [self.view addSubview:vcRegister.view];
    [self addChildViewController:vcRegister];

    if (IS_IPAD()) {
        vcRegister.view.center = self.view.center;
    }

    [vcLogin willMoveToParentViewController:nil];

    [self transitionFromViewController:vcLogin toViewController:vcRegister duration:0.5f options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{} completion:^(BOOL finished) {
        [vcLogin removeFromParentViewController];
        [vcRegister didMoveToParentViewController:self];
    }];
}

I also tried with [UIView transitionFromView:...] but the result is the same! Any suggestions? Thanks!

Upvotes: 0

Views: 323

Answers (1)

Ben Coffman
Ben Coffman

Reputation: 1740

Have you tried core animation? You might use something like the code below and have one view controller with subviews.

    [UIView transitionFromView:viewOne
                        toView:viewTwo
                      duration:1.0f
                       options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionShowHideTransitionViews
                    completion:(^(BOOL finished){
    })];

Upvotes: 0

Related Questions