[英]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.