仅在横向模式下锁定应用

时间:2011-06-07 04:10:03

标签: objective-c cocoa-touch xcode ipad landscape-portrait

在我的应用程序中,我的条件是仅在横向模式下启动我的应用程序。所以我将以这种方式旋转到界面方向: -

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

但是我的应用程序首先尝试以纵向模式加载,然后在屏幕看起来拉伸的过程中。我错过了什么吗?请建议。任何帮助将不胜感激

谢谢,
克里斯蒂

2 个答案:

答案 0 :(得分:1)

您说上面的代码位于-(void)willRotateToOrientation时应该放在-(BOOL)shouldRotateToOrientation中。

假设这是一个拼写错误,请将Info.plist文件中支持的方向设置为LandscapeRight和LandscapeLeft。

答案 1 :(得分:0)

只是为了确保克里斯蒂娜在对其他答案的评论中的修正不会错过:

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight

我在didFinishLaunching app delegate函数中添加了这个,它似乎强制一个视图控制器刷新,在我的情况下确保OpenGL帧缓冲区是以正确的尺寸创建的,奇怪的是我必须添加它。