Search code examples
iphoneios7

UIViewController Transition from right to left


I am opening second view controller on button click from fist viewController,but its animating from bottom.I want to open it in right to left.


Solution

  • You may be presenting the second view controller on first view button tap.

    The view transition from right to left will work when you do pushing a second view. For enable pushing the second view, at first your first view should be inside navigation controller. If your first view is already inside a navigation controller then do the following for pushing second view: Case 1: If your are using storyboard and First view is already embedded in Navigation controller

    1. set storyboardID for the second view controller in storyboard (Eg. here storyboardID is same as the class name)

    2. Do this code on your button tap of first view:

       SecondViewController *secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
      [self.navigationController pushViewController:secondViewController animates:YES];
      

    Case 2: If you are using storyboard but First view controller is not embedded in Navigation Controller: 1. Embed the First view in Navigarion controller

    1.1. Open storyboard file and select the First View Controller

    1.2. Goto Editor->Embed In-> Navigation Controller.

    1. Then do the step Case:1's 2nd step.

    Case 3: If you are using XIB files and first view is not in navigation controller. 1. For loading first view in AppDelegate.m application:didFnishLoading: method do as follows:

    FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
    self.window.rootViewController = navigationController;
    
    1. Then for pushing second view on first view button do as follows:

       SecondViewController *secondViewController = [[FirstViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
      [self.navigationController pushViewController:secondViewController animates:YES];
      

    If this is not helpful, then just post what you did exactly then exact solution can be given. Because what approach you are using to load view is not mentioned in your question.