在ios7/Xcode 5中将方向锁定到横向右侧

在ios7/Xcode 5中将方向锁定到横向右侧,ios,xcode5,device-orientation,Ios,Xcode5,Device Orientation,我知道以前有人问过这个问题,但我还没有找到解决办法。在Xcode 5中,我想将我的应用程序锁定到右侧。以下是我为建立项目所采取的步骤 (1) 创建单个视图项目 (2) 在“常规设置”选项卡下,将设备方向设置为向右横向 (3) 在main.storyboard中将视图控制器方向设置为横向 (4) 将以下代码添加到ViewController.m -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interf

我知道以前有人问过这个问题,但我还没有找到解决办法。在Xcode 5中,我想将我的应用程序锁定到右侧。以下是我为建立项目所采取的步骤

(1) 创建单个视图项目

(2) 在“常规设置”选项卡下,将设备方向设置为向右横向

(3) 在main.storyboard中将视图控制器方向设置为横向

(4) 将以下代码添加到ViewController.m

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

-(NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight;
}
(5) 将以下代码添加到ViewController viewdidLoad

NSLog(@"frame %f %f", self.view.frame.size.width, self.view.frame.size.height);
每次运行应用程序时,我的视图都是320 x 568

我需要设置什么才能获得横向视图(568 x 320)


多谢各位

即使设备更改为横向模式,设备/视图的宽度和高度也将相同,并且始终返回320 x 568


区别在于用户在横向视图中查看设备。它不会给你在宽度和高度上的变化,正如你所期望的那样

-(BOOL)shouldAutorotate{return YES;}也没有效果。好的,当视图明显超过320宽时,这看起来很奇怪。这里的视图高度在纵向和横向中保持相同,但如果需要在视图中重新定位按钮/控件,则视图会有所不同。使用自动调整大小