iPhone - adding views and landscape orientation
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, whi开发者_如何学Pythonle the view of controller2 is rotated by 90 degrees. Does anyone have an idea how this can happen? Thanks for your help.
Perhaps you shoud put
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
also in your mainMenuViewController
精彩评论