How to restrict my app to landscape mode?

前端 未结 4 1398
不思量自难忘°
不思量自难忘° 2020-12-13 07:52

I have my iPad application created using the SplitView template. I wonder what is the best way to restrict my application to landscape mode?

I have tried overriding

4条回答
  •  鱼传尺愫
    2020-12-13 08:18

    I believe this is a BUG, I faced this problem also. It is something to do with

    UIInterfaceOrientationLandscapeLeft
    

    To replicate this situation:

    1) Create a new iPad project using UISplitViewController template

    2) Edit info.plist

    Supported interface orientations
    -Landscape (left home button)
    -Landscape (right home button)
    

    3) DetailViewController.m

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    //    return YES;
     NSLog(@"RotateToInterface:[%d] vs LandscapeLeft[%d]", interfaceOrientation, UIInterfaceOrientationLandscapeLeft);
     return interfaceOrientation == UIInterfaceOrientationLandscapeLeft;
    }
    

    4) Run it....You will see a blank black view. and no matter how you turn. "UIInterfaceOrientationLandscapeLeft" never detected.

    By the way, nacho4d's adding BOOL check work-around is working. Thumbs UP :)

提交回复
热议问题