Turning off “Use Autolayout” causes app to only run in portrait mode

不想你离开。 提交于 2019-12-24 13:30:24

问题


I want my app to be compatible with iOS 5, so I had to disable "Use Autolayout" in the XIB files. The whole app is designed to be run in landscape mode. When the app is launched after disabling autolayout (whether in iOS 5 or iOS 6), the app always launches in portrait mode and refuses to rotate to landscape.

In Info.plist, Supported Interface Orientations (iPad) is set only to landscape. What am I doing wrong? This only occurs after disabling autolayout.


回答1:


I was able to fix the issue in iOS 6 by using Ismael's answer.

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;

}

I was able to fix it in iOS 5 by using the code below.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);

}



回答2:


Add this to your controller:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

Edit: If you don't want to support portrait, you should return NO in shouldAutorotate



来源:https://stackoverflow.com/questions/14073057/turning-off-use-autolayout-causes-app-to-only-run-in-portrait-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!