简体   繁体   English

iOS 5.0模式视图不旋转(故事板)

[英]iOS 5.0 Modal View Not Rotating(Story Boards)

I use story boards. 我使用故事板。 In every view controler I want to rotate I included this method like this: 在每个我想旋转的视图控制器中,我都包含了这样的方法:

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

in iOS 6 it rotates just fine to the proper views I have for landscape and portrait in my story boards. 在iOS 6中,它可以旋转到故事板上我对横向和纵向的适当视图。

in iOS 5 the parent view contoller rotates but the modals don't rotate while they are on the screen, they only rotate before they are on the screen but never during. 在iOS 5中,父视图控制框会旋转,但是模式在屏幕上时不会旋转,它们只会在屏幕上之前旋转,而不会在屏幕上旋转。 So when a user changes orientation it remains the same. 因此,当用户更改方向时,它保持不变。 A parent will change while on screen but the modal will take on the orientation the parent had but will not change while on screen. 父对象将在屏幕上发生变化,但模态将采用父对象所具有的方向,但在屏幕上不会发生变化。 How do I get my modal views to work like iOS 6 where they will rotate when on the screen. 如何使模态视图像iOS 6一样工作,它们在屏幕上时将旋转。 The modal view were created via the storyboard. 模态视图是通过情节提要创建的。

Edit* 编辑*

When I do a popover to a modal, the modal doesn't rotate. 当我对模式进行弹出时,模式不会旋转。 How can I fix this? 我怎样才能解决这个问题?

Rotation is handled differently in iOS5 and iOS6. 旋转在iOS5和iOS6中的处理方式有所不同。 I use the below code to support both versions. 我使用以下代码支持两个版本。

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

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

- (BOOL)shouldAutorotate
{
    return YES;
}

shouldAutorotateToInterfaceOrientation: is deprecated in iOS6. shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:在iOS6中已弃用。 You can read here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation : 您可以在此处阅读: http : //developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM