ios 5下设置屏幕方向为landscape

问题:

在ios6之下,只要在Target的summary中设置成如下即可。

这个对ios6管用,但对ios5不管用。网上有人说在Info.plist中设置

Initial interface orientation = Landscape (left home button)

试验了一下,ios5下仍然不管用。

解决方案。

在每个屏幕方向需要变换成landscape的viewController中添加如下代码即可。

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;

}

原文地址:https://www.cnblogs.com/mobileinternet/p/3038244.html