将我的项目从竖屏转为横屏方向时出现问题。

3
我已经开发了我的项目,但是它只支持竖屏模式,现在我想将其设置为横屏模式。我已经将所有xib文件的方向属性设置为横屏,并且在.plist文件中也将所有Supported interface orientations的项目设置为横屏,但是当我运行我的项目时,仍然有一个视图以竖屏模式显示... 在这个视图中,我正在显示PDF文件。
提前感谢!!!

当屏幕方向改变时,请尝试设置该元素的框架。 - ThE uSeFuL
你的意思是所有视图都应该更改为横向方向,无论当前方向如何。 - SNR
2个回答

2
你是否将以下方法放入了你的视图控制器中?
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

我觉得你可能忘记放那个函数了,哈哈,所以我回答了那个问题。 - Kshitiz Ghimire

1
如果是横向模式,请使用此代码。
(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}

如果是竖屏,请使用这段代码。
(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接