我有一个应用程序,所有屏幕都在纵向除了一个。在iOS 8中,一个横向页面显示正常,直到设备向任何方向旋转。视图在一个奇怪的轴上旋转,其中一部分离开屏幕。 我已尝试在viewWillTransitionToSize中更新视图的框架,但它只会导致更多问题,将子视图的帧更改为超级疯狂。 一些解决方案建议这样做:
- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
[UIViewController attemptRotationToDeviceOrientation];
}
但这对我没有用。有任何想法吗?谢谢!
答案 0 :(得分:2)
违规行将在您的AppDelegate didFinishLaunchingWithOptions函数中,如下所示:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
答案 1 :(得分:0)
请试一试。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这将允许左右两个横向(但自iOS6以来它已弃用)。
或者这个,但我没有测试它。
- (BOOL)shouldAutorotate {
return NO;
}