支持的接口方向和shouldAutorotateToInterfaceOrientation

时间:2013-03-26 05:12:30

标签: iphone ios objective-c

在我的项目设置中,我将支持接口方向作为两种格局。

我是否仍应在每个视图控制器中实现以下内容?

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

2 个答案:

答案 0 :(得分:3)

iOS< 6.x的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation // Deprecated in iOS 6.x 
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

iOS> 6.x的

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
希望这会有所帮助。

答案 1 :(得分:0)

你的实施效果更好,如果你在info.plist中实现横向的方向

会更好

for ios> 6

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}