tags:

views:

25

answers:

1

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.

A: 

Perhaps you shoud put

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

also in your mainMenuViewController

Samuel
that's exactly what i did.the problem is, that the orientation works for the first instance. the second instance gets rotated by 90 degrees.i now made a workaround by attaching a view between my window and my custom views that i change by code. this seems to work. nevertheless it's a strange behavior i don't understand.
Franz