0

In my app there is a main table view. When a cell is clicked, a DetailView is created which shows details of that cell's item. On every DetailView i have next and previous buttons which helps users to go to next and previous item's DetailView without going back to RootView. When i click next button. animation is from right to left. and its same when i click previous button. Animation should be from left to right when i click previous button. Is there anyways to change that animation direction. I don't wanna use [self.navigationController popViewControllerAnimated:YES], because i have alot of items and its hard to take care of navigation stack. So is there any way i can change right to left animation to left to right when i click previous button.

Piscean
  • 3,069
  • 12
  • 47
  • 96

1 Answers1

1

It could be implemented a navigation controller and push and pop, and you don't have to deal with a messy navigation stack because what you have to do is just 1) push a view and remove the previous view from the stack (in 'next' case), or 2) insert a view into the stack in front of the current view and pop the current view (in 'previous' case).

So far, however, I see no reason to use a navigation controller here. When you are switching to a new detail view, prepare the new view as hidden and insert the view on top of the view layers. Then, create a CATransition object with desired options, unhide the new view, and deal with the previous detail view (like, remove it). For example,

CATransition transition = [CATransition animation];
transition.duration = 0.75;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = (nextDidPressed)? kCATransitionFromRight : kCATransitionFromLeft;
newDetailView.hidden = NO;
detailView.hidden = YES;
self.detailView = newDetailView;

The above code makes a few assumptions on your view layouts and declared properties. Make changes according to the other part of your code appropriately.

MHC
  • 6,405
  • 2
  • 25
  • 26
  • See ViewTransitions sample project for details. – MHC Feb 12 '11 at 19:58
  • well i took ur first advise. it was really easy. and thats cool that we dont have to worry about navigation stack. well i m quite new in this. but got it. thanx for ur help bro. take care – Piscean Feb 12 '11 at 20:41