Pergunta

i want to add two subviews to window in my AppDelegateController. both in landscape mode. when i add the first view, it is in landscape (that's fine), but when adding the second, it is automatically in portrait mode. any advice?

thanks + regards

that's in my AppDelegate.m

[window addSubview:viewController.view];

CGRect frame = startviewController.view.frame;

frame.origin.x = 400;
frame.origin.y = 0;

startviewController.view.frame = frame;

[window addSubview:startviewController.view];

that's in my AppDelegate.h

@class LearnShiftViewController;
@class StartViewController;

@interface LearnShiftAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    LearnShiftViewController *viewController;
  StartViewController *startviewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LearnShiftViewController *viewController;
@property (nonatomic, retain) IBOutlet StartViewController *startviewController;

In my MainWindow.xib I added both view controllers I want to add as subviews!

My way to make them landscape is putting this in the shouldAutorotateToInterfaceOrientation method of both view controllers:

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

and set the orientation to Landscape in InterfaceBuilder.

Foi útil?

Solução

okay guys, i fixed it myself.

i added a DummyViewController, where I add the two SubViews. So only one view is added to the window. Works flawlessly now :) But thanks anyway!

Outras dicas

Are you sure landscape mode is enabled for second view?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top