简体   繁体   English

iOS:从LandScape ViewController切换到Portrait ViewController

[英]iOS: Switching to Portrait ViewController from LandScape ViewController

I have a VC in Portrait which presents another VC that can either be portrait or landscape. 我在Portrait中有一个VC,它提供了另一个可以是纵向或横向的VC。 The problem is that when I return back to the original VC that presented it, it is also shown in landscape until I rotate it and then it stays in portrait. 问题在于,当我返回展示它的原始VC时,它也会以横向显示,直到我旋转它,然后再保持纵向。 What I want is to always have the original VC to always be portrait, how can I achieve this? 我想要的是始终拥有原始的VC始终是肖像,我该如何实现? Here it the code that I use to set up the VC orientations after I have set the supported orientations in my PList: 在我在PList中设置受支持的方向之后,这里是用于设置VC方向的代码:

In the original VC, that should always be portrait 在原始的VC中,应该始终是纵向的

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

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

In my VC that could either be portrait or landscape, I have: 在我的VC中可以是纵向或横向的,我有:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

Override the supportedInterfaceOrientations method and return UIInterfaceOrientationMaskPortraitUpsideDown. 重写supportedInterfaceOrientations方法,并返回UIInterfaceOrientationMaskPortraitUpsideDown。

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortraitUpsideDown;
}

暂无
暂无

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

相关问题 来自.xib文件的ViewController在iOS中以纵向模式而不是横向模式加载 - ViewController from .xib file is loading in portrait mode and not in landscape mode in iOS 在一个viewController中为人像,在另一个viewController中为风景 - Portrait in one viewController and landscape in another 如何在iOS中将人像之类的ViewView模式更改为横向模式? - How to change One ViewController mode like Portrait to landscape in iOS? 在iOS上从横向视图切换到纵向视图 - Switching from Landscape View to Portrait View on iOS 在iOS 7中强制使用Landscape ViewController - Force Landscape ViewController in iOS 7 如何在swift中从iPhone的肖像底部呈现仅景观ViewController? - How to present a landscape only ViewController from portrait bottom of iPhone in swift? IOS 6方向 - 只有一个Viewcontroller支持横向和纵向方向 - 否则只支持纵向 - IOS 6 Orientations - Only One Viewcontroller supports Landscape & Portrait orientation - else ONLY Portrait 纵向模式下的第一个ViewController和横向模式下的SecondViewController - 1st ViewController in Portrait and SecondViewController in Landscape Mode 仅一个视图控制器中的横向和纵向方向 - Landscape and portrait orientations in only one viewcontroller 从横向ViewController返回后,支持所有方向更改为横向的iOS ViewController - iOS ViewController that supports all orientations changes to landscape after returning from landscape ViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM