简体   繁体   English

iOS:我的故事板为横向,项目设置为横向,但在模拟器中仍然错误

[英]iOS: My storyboard is landscape and project is set to landscape but still wrong in simulator

I want to make a landscape iPad app. 我想制作一个风景iPad应用程序。 I did below 3 things. 我做了以下三件事。 the simulator orientation is landscape which is correct. 模拟器的方向是风景,这是正确的。 However, the content is 90 degrees wrong, but they are right in the storyboard view, landscape. 但是,内容错了90度,但它们在情节提要图板视图中是正确的。 Is there anything I need to check? 我需要检查什么吗?

  1. I set my storyboard as landscape. 我将情节提要设置为风景。

  2. May project I already set "supported interface orientations" = landscape 可能项目我已经设置了“支持的界面方向” =横向

  3. Also used this code in view controller: 在视图控制器中也使用了以下代码:

     - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) return YES; else return NO; } 

Supported Interface Orientations is one thing. 支持的接口方向是一回事。 It didn't work for me until I did the following: 在执行以下操作之前,它对我不起作用:

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

You have to use the following code on ALL of your viewcontrollers 您必须在所有ViewController上使用以下代码

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

确保在Info.plist中也设置了“初始界面方向”。

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

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