Search code examples
iosswiftstoryboardios-animations

Show UINavigationController with UIViewController animation


I have a storyboard with few UINavigationControllers and UIViewControllers.

Main.storyboard

When I performSegueWithIdentifier(..) from the second to third window default animation is right to left slide. But when I performSegueWithIdentifier(..) from the third window to UINavigationController the animation is from bottom to top slide. How to set UIViewController -> UINavigationController animation to one like UIViewController -> UIViewController?


Solution

  • YOURVC *vc = [[YOURVC alloc]init];
    UINavigationController *VCNavigation = [[UINavigationController alloc]initWithRootViewController:vc];
    

    And when you are calling from 1 to 3 or any call

    [self.navigationController pushViewController:vc animated:YES];
    

    or from 2 to 1 also you can call like this and instead you can call

    [self.navigationController popViewControllerAnimated:YES];
    

    or to root view controller use

    [self.navigationController popToRootViewControllerAnimated:YES];
    

    or to a particular vc

    [self.navigationController popToViewController:yourvc Animated:YES];
    

    Then if you want to show navigation keep it, or if you want to hide you can hide it.