1

I want to have a custom transition between two navigation controllers. Let's call the first one sourceController and the other one detailNavController.

Here's my code:

NewEntryViewController *viewController = [[NewEntryViewController alloc] 
                                                                  initWithStyle:UITableViewStyleGrouped];
viewController.parentController = self;

UINavigationController *detailNavController = [[UINavigationController alloc]
                                                                  initWithRootViewController:viewController];

[UIView beginAnimations:nil context:NULL];
[self.navigationController presentModalViewController:detailNavController animated:NO];

[UIView setAnimationDuration:0.4];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:sourceController.view cache:YES];

[UIView commitAnimations];

SourceController was first presented modally, that's why I'm presenting detailNavController modally. The problem with this code is that the animation takes place, but sourceController is still on top of the new detailNavController. What I would like to achieve is to have the animation and then dismiss sourceController and have detailNavController displayed.

1 Answer 1

1

I've finally found the solution for this, here's the updated code:

- (void)createNewEntryWithAnimation
{
    // before calling this method I dismissed sourceController without animation
    NewEntryViewController *viewController = [[NewEntryViewController alloc] initWithStyle:UITableViewStyleGrouped];
    viewController.parentController = self;

    UINavigationController *detailNavController = [[UINavigationController alloc] 
                                                   initWithRootViewController:viewController];

    [UIView beginAnimations:nil context:NULL];
    [self.navigationController presentModalViewController:detailNavController animated:NO];

    [UIView setAnimationDuration:0.4];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view.window cache:NO];

    [UIView commitAnimations];
}

I had to use cache:NO, otherwise the transition wasn't smooth.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.