1

I m making an app which has a main TableView. when we click any cell we got DetailView of that cell. we can also change DetailView without going back to main TableView by using next and prev button on every DetailView. When i click prev button. I get previous item'd DetailView but animation is like its going forward. i m using this:

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

can anybody tell me how can i change that animation like Back button animation.

Thanx in advance

Piscean
  • 3,069
  • 12
  • 47
  • 96

1 Answers1

1

You have to store your navigationController, then 'pop' your current view with an animation and 'push' the detail view without an animation, for example like Squeegy did here. I've adjusted Squeegy's code a bit, the following should work:

// locally store the navigation controller since
// self.navigationController will be nil once we are popped
UINavigationController *navController = self.navigationController;
// retain ourselves so that the controller will still exist once it's popped off
[[self retain] autorelease];

// Pop this controller and replace with another
[navController popViewControllerAnimated:YES];
[navController pushViewController:prevView animated:NO];
Community
  • 1
  • 1
Philipp
  • 1,903
  • 2
  • 24
  • 33
  • [navController popViewControllerAnimated:YES]; does the same like [navController popViewControllerAnimated:YES]; [navController pushViewController:prevView animated:NO]; and i dont understand how to fix that thing. i think it should work fine. 2nd statement should replace the first one but its not doing like that. thats y if 3rd item is clicked and then u click prev button it goes to root view instead of 2nd detail view. – Piscean Feb 10 '11 at 21:02
  • - (IBAction)previousPage:(id)sender {displayedObjectIndex--; NSString *storyyTitle = [[allObjects objectAtIndex:displayedObjectIndex] objectForKey:@"title"]; prevController.sTitle = storyyTitle; [self.navigationController popViewControllerAnimated:YES]; [self.navigationController pushViewController:prevController animated:No]; [prevController initWithObjectAtIndex:displayedObjectIndex inArray:allObjects]; [prevController release]; }------------- its is in DetailViewController.m. I am very new beginner. learning by myself. dont have very good concepts so don't get angry with the code :) – Piscean Feb 10 '11 at 21:44
  • infact i m creating a detail view controller everytime previous or next button is clicked. and then replace it with current controller. working fine but with that back animation code i got problem. i ll b very thankful to u if u can give me some nice way to solve it. – Piscean Feb 10 '11 at 21:46