2013-01-18 95 views
0

我使用故事板。在每个视图CONTROLER我想旋转包括我这个方法是这样的:iOS 5.0 Modal View不旋转(故事板)

- (BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)toInterfaceOrientation { 
    return YES; 
} 

在iOS 6中它旋转就好在我的故事板我有横向和纵向的正确意见。

在iOS 5父视图控制器旋转,但模式不旋转,而他们在屏幕上,他们只旋转之前,他们在屏幕上,但从来没有在期间。所以当用户改变方向时,它仍然是一样的。父母在屏幕上将会改变,但是模态会采取父母的方向,但不会在屏幕上改变。如何让我的模态视图像iOS 6一样在屏幕上旋转。模态视图是通过故事板创建的。

编辑*

当我做酥料饼的模式,模式不旋转。我怎样才能解决这个问题?

回答

1

旋转在iOS5和iOS6中处理方式不同。我使用下面的代码来支持这两个版本。

// iOS5 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// iOS6 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

shouldAutorotateToInterfaceOrientation:已在iOS6中弃用。你可以在这里阅读:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation

+0

这很有趣,因为它可以在iOS6上正常工作,稍后我会处理该弃用。但我确实使用 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 对于iOS 5,但问题是,它不是在模态视图上旋转。 – user1837396

+0

对不起,我没有正确阅读这个问题哈哈。这是代码而不是模态viewController和viewController呈现模式? –

+0

用户在iOS 5 iPad上启动应用程序。在第一个屏幕上旋转时,它会自动旋转。 当他们点击一个按钮时,下一个视图将以模态方式呈现,并且将以任意方向显示第一个视图。 当用户更改方向时,当模型视图向上时,屏幕不会改变方向,直到模态视图已关闭。 – user1837396