views:

254

answers:

1

I am working on a Navigation-Based Application. I have few View Controllers which I push in to Navigation Controller on different occasions. The following is the code I use to push new View Controller.

AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
[self.navigationController pushViewController:anotherViewController animated:YES];
[anotherViewController release];

One thing i noticed is that, when new view controller is pushed the navigation bar also animated (slided). I have a back button, title text and right button in navigation bar. So it look wiered when navigation bar is animated.

Is there any way around to keep the navigation bar fixed and the view is only animated when new view controller is pushed?

A: 

I tried a lot of different approaches but nothing worked. Finally I use a workaround:

1) Hand over the current view (self.view) of the first view controller to the second view controller 2) Do a pushViewController with e.g. a fade transition. Set the second view controller as delegate of the animation to inform the second controller if transition is finished 3) In viewDidLoad of second view controller save the view of the second view controller and set the view of the first one as self.view

Now the display should look like the content of the first view controller with the navigation bar (and toolbar if so) of the second one.

Finally perform in the second view controller (in delegate method of animation) the transition you want to do for the content e.g. flip.

Basically that works. I have still to resolve some issues with correct position of the view and restoring the view in the first view controller for my app.

But this should give you a hint at least.

Update: Fixed remaining issues. It was a bit tricky because the first view controller resides in a scrollview. Flipping out was not a big deal, but flipping back into a scroll view is a nasty thing.

Gerd