0

I am woundering if its possible to change the navigation controller animation to something where instead of the new view just sliding onto the view, having the current view slide off as the new view slides on...

I have this function here, which is just detecting my swipes then animating the views like a normal navigationcontroller would do.. but I am hoping I can figure something else out with your help.

// Need to change this to work with viewArray
- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture {

    //Left swipe
    if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) 
    {
        if (viewCount == 0) 
        {     
            viewCount += 1;
            // Load a detial view into the (sub)NavController
            DetailViewControllerA *detailViewA = [[DetailViewControllerA alloc] initWithNibName:@"DetailViewControllerA" bundle:[NSBundle mainBundle]];
            [otherNav pushViewController:detailViewA animated:YES];
        }
    }
    //Right swipe
    else if (gesture.direction == UISwipeGestureRecognizerDirectionRight)
    {
        if (viewCount == 1) 
        {
            viewCount -= 1;
            [self.otherNav popViewControllerAnimated:YES]; 
        }
    }  
}
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
  • Have a look at this post: http://stackoverflow.com/questions/4869787/uinavigationcontroller-custom-animation – iTukker Jun 01 '12 at 05:22
  • hrmm... from what I can tell its not quite what I am looking to do its only transitioning the one page and from the top I think.. but still I don't even get how hes adding it to a navigation controller.. man this has become a big head ach. lol – HurkNburkS Jun 01 '12 at 06:20
  • Yes, the example is from the top, but you can change the animation to anything you like. You don't add it to the navigation controller, you control it from your viewController. If you have multiple viewControllers you could subclass UIViewController to implement the logic. You could also create a category for the UIViewController – iTukker Jun 01 '12 at 06:29

1 Answers1

1

You can do this with the uiView animation blocks like this one i use to show one blinking UIView

[UIView animateWithDuration:1.0 
                          delay:0.0 
                        options:UIViewAnimationCurveEaseInOut 
                     animations:^ {
                         self.splash.alpha = 0.2;
                     } 
                     completion:^(BOOL finished) {
                         [UIView animateWithDuration:1.0 animations:^{
                             self.splash.alpha = 1.0;
                         }];
                     }];

or

using below code

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.window cache:YES];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationDelegate:self];
    [self.splash removeFromSuperview];
    [UIView commitAnimations];

for flip transition

and for changing push/pop animation i use this code

    [UIView  beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController:self.detailViewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];

enjoy Codding :)

Happy Codding :)

The iOSDev
  • 5,237
  • 7
  • 41
  • 78