问题
I have a piano app in the App Store. It works in landscape mode.
Now iOS 7 appears to be ignoring the Landscape setting in IB
The app works as expected in iOS 6 and below, in landscape. In iOS 7 appears in portrait. Here are settings and relevant code:
//iOS 6+
- (BOOL)shouldAutorotate
{
return YES;
}
//iOS 6+
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}
//iOS 5.1.1-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
回答1:
Thanks to @shawnwall comment I realised I didn't have a Root View Controller. In the past my app given support yo iOS 3.1.3 O_O:
[self.window addSubview:self.viewController.view];
I dropped 3.1.3 support a long time ago, so I can set up a root view controller:
self.window.rootViewController = self.viewController;
That was the thing that caused the visual bug.
来源:https://stackoverflow.com/questions/18857964/landscape-apps-xcode-5-ios-7