0

Hey, just wondering how/if possible to get a UITableView to animate from top to bottom. The standard way of doing a transition animated the page bottom to top, bu I have an undo button on the page that I navigate to that I want to allow the user to click if they decide to go back... This is my code for the current animation that goes bottom to top.. if you could help me to change it that would be awesome.

  - (void)viewDidLoad { 

    //Title
    self.title = @"Advanced Search";
    [super viewDidLoad];    

    //undo button takes you back to main search options
    UIBarButtonItem *undoButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemUndo target:self action:@selector(undoButton:)];
    self.navigationItem.leftBarButtonItem = undoButton;
}

- (void)undoButton:sender {
    RootViewController *rootViewController = [[RootViewController alloc] init];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
    [[self navigationController] presentModalViewController:navigationController animated:YES];
    [navigationController release];

}
tinhead
  • 385
  • 2
  • 10
  • 29

1 Answers1

0

I dont think top to bottom animation is available but you can still do that with UIView animation block.

The only thing you should do is change the frame of the view you are presenting . Initially set it to the top frame like CGRectMake(0,0,320,0) . Then in an animation block change the frame to CGRectMake(0,0,320,480). This will make it look like coming from the top . And you need to do the reverse when hiding it again .

[UIView beginAnimations:@"AnimatePresent" context:view];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelegate:self];

view.frame = CGRectMake(0, 0 , 320, 480);

[UIView commitAnimations];

Hope this helps !!

Bharat Jagtap
  • 1,692
  • 2
  • 22
  • 35