简体   繁体   中英

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

I want to make a landscape iPad app. 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. 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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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