iPhone - adding views and landscape orientation
Posted
by Franz
on Stack Overflow
See other posts from Stack Overflow
or by Franz
Published on 2010-06-16T09:19:47Z
Indexed on
2010/06/16
9:22 UTC
Read the original article
Hit count: 285
iphone
I got a problem with Cocoa touch and landscape orientation.
I instantiate my view from a .xib; i added in my view controller
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
to only allow landscape orientation.
This works find for the first view i add.. if I add a second view however it is rotated again like the landscape view is shown in portrait mode (rotated 90 degree counterclockwise).
I really don't know what is going on and can't find a workaround. I even tried to get behind what is happening just adding my view twice:
MainMenuViewController* controller = [[MainMenuViewController alloc] initWithNibName:@"MainMenu" bundle:nil];
[window addSubview: controller.view];
MainMenuViewController* controller2 = [[MainMenuViewController alloc] initWithNibName:@"MainMenu" bundle:nil];
[window addSubview: controller2.view];
[window makeKeyAndVisible];
The view of controller is displayed correctly, while the view of controller2 is rotated by 90 degrees. Does anyone have an idea how this can happen? Thanks for your help.
© Stack Overflow or respective owner