问题
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