views:

378

answers:

1

I have a regular UINavigationController and I push a series of UIViewController into the stack. The view transition for push controller is horizontal animation transition: [self.navigationController pushViewController:controller animated:YES];

However, when I press the Back button on the navigation bar, the view transition animation is vertical (vertically dropping down the previous controller/view).

I don't seem to find any way to make this horizontal. This happens only in Landscape mode. Portrait mode the transition all happens as horizontal flip transition.

Can anyone shed any light on this?

Thanks

A: 

I had the same problem. When I pressed back to get to the first view I saw a vertical animation instead of the normal horizontal one.

I found an answer based on Apple's NavBar sample code. I edited the sample code to add "shouldAutorotateToInterfaceOrientation" to all the view controllers, and made it return YES.

When I ran it I noticed the correct animation was used when pressing "Back".

FIX:

It seems like you need to use your own subclassed UIViewController within the navigation controller, and add shouldAutorotateToInterfaceOrientation. Presumably the default UIViewController isn't returning the correct orientation so the wrong animation is used.

BACKGROUND:

I checked all the differences between my code and Apple's, and I found out that my navigation controller was a subclass of UINavigationController, where I perform all the work. By default IB had added a UIViewController inside this, and I left it alone. I noticed that the NavBar sample code had its own class set (MainViewController). So I made Xcode create a new UIViewController subclass with no xib, then set it up in the Class option in the Identity panel in IB.

I hope this makes sense and helps!

alex