2010-09-08 65 views
0

我想在我的AppDelegateController窗口中添加两个子视图。无论是在横向模式。当我添加第一个视图时,它在横向(这很好),但是当添加第二个视图时,它会自动处于纵向模式。有什么建议?在窗口addsubview问题

感谢+问候

这是在我的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]; 

这是在我的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; 

在我的MainWindow.xib我加这两个视图控制器我想添加为子视图小号!

我的办法使它们景观把这个两个视图控制器的shouldAutorotateToInterfaceOrientation方法:

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 

,并设置方向设置为横向InterfaceBuilder下。

+0

也许有些代码会有所帮助。你如何使它景观?你怎么启动子视图? – 2010-09-08 20:56:16

回答

1

好男人,我自己修复它。

我添加了一个DummyViewController,我添加了两个SubViews。所以只有一个视图被添加到窗口中。完美无缺地工作:)但无论如何,谢谢!

0

你确定风景模式已启用第二个视图吗?

+0

好吧,在IB中的ViewController .xibs和MainWindow.xib中,一切都设置为Orientation:Landscape! – Tronic 2010-09-08 21:37:42

+0

和shouldAutorotateToInterfaceOrientation方法呢,它应该返回YES或类似于interfaceOrientation == UIInterfaceOrientationLandscapeLeft – eviltrue 2010-09-09 11:22:38