3

I'm doing an universal ios game and I'm having an orientation problem. My app is all in landscape mode. If I do presentModelViewController is all ok, but if I do setRootViewController, the new controller appear in portrait mode.

What am I doing wrong?

António
  • 435
  • 7
  • 17
  • have you solved this one? I'm facing the same weird issue, changing RootViewController later on will bring the newly-presented view controller in portrait mode for a short while and rotate it to landscape mode – Chris Chen Nov 08 '11 at 06:37

2 Answers2

1

I'm unsure if this was your problem, but I have an application that starts with one view controller in portrait mode and then I'm trying to present a second view controller in landscape mode. I'm using the setRootViewController technique as well so that I do not have to deallocate/reallocate the second view controller and lose my state information since users will be switching between the two views frequently.

I had the same issue where the second view controller would always be displayed in portrait mode instead of landscape, even though the view controller itself specifies that it never allows portrait mode.

The fix for me was to make sure that in the application delegate I presented the first view controller using

[window setRootViewController:controller];

instead of

[window addSubview:controller.view];

This was an older application, and the original template used addSubview by default. it seems that if there was not an original root view controller specified, the necessary orientation messages will never make it to subsequent view controllers that are set as root. Hope that helps!

jzn
  • 656
  • 10
  • 17
0

Have you set the

UIInterfaceOrientation

key in your info.plist file to your desired orientation? (in this case landscape)

  • I have done that already. If i add the controllar at the beginning of app with setRootViewController, its all ok, but if i add that after i add other controllers, they will have these weird beaver. – António Jun 30 '11 at 10:55
  • AddChildNavigationController * navCon = [[AddChildNavigationController alloc] initMe]; UIWindow * window = [[UIApplication sharedApplication] keyWindow]; [window setRootViewController:navCon]; [window makeKeyAndVisible]; [navCon release]; – António Jun 30 '11 at 14:00
  • Is this within your `application:didFinishLaunchingWithOptions:` method or somewhere else? Also, how are you handling rotation in the `shouldAutorotateToInterfaceOrientation:` method of **AddChildNavigationController** ? –  Jun 30 '11 at 14:04