简体   繁体   English

只有一个视图控制器响应方向设置

[英]Only One View Controller Responds To Orientation Settings

I'm very new to storyboards and objective-c in general. 我对故事板和目标c都很新。 Basically, I have a welcome screen with 4 buttons on it. 基本上,我有一个欢迎屏幕,上面有4个按钮。 Each button loads a new scene via the modal way. 每个按钮通过模态方式加载新场景。 I added the 3 new screens by dragging a View Controller onto the page. 我通过将视图控制器拖到页面上添加了3个新屏幕。 I only have one View Controller file also. 我也只有一个View Controller文件。 I added this code in to make it support Landscape only mode: 我添加了此代码,使其支持仅横向模式:

 // For iOS 5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
// For IOS 6

-(BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeLeft;
}

Now, for some reason only the original view controller (The one that first came with the storyboard, and not the View Controllers I dragged on) responds to this code. 现在,出于某种原因,只有原始视图控制器(首先附带故事板的那个,而不是我拖动的视图控制器)响应此代码。 I'm extremely new to this and have no idea how to fix this. 我对此非常陌生,不知道如何解决这个问题。

I think I need to create new .h and .m view controller files for each view controller, and add that code in there. 我想我需要为每个视图控制器创建新的.h和.m视图控制器文件,并在那里添加该代码。 My only question is, how do I link those files to the view controllers in the Storyboard? 我唯一的问题是,如何将这些文件链接到Storyboard中的视图控制器?

In storyboard, select the view controller, then the Identity Inspector tab. 在storyboard中,选择视图控制器,然后选择Identity Inspector选项卡。 The top field is labeled "Class". 顶部字段标记为“类”。 Enter the name of your custom class in that field. 在该字段中输入自定义类的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM