从横向视图控制器推动时强制纵向方向 [英] Force portrait orientation while pushing from landscape View Controller

查看:174
本文介绍了从横向视图控制器推动时强制纵向方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用支持:iOS6 +

App Support: iOS6+

我的应用程序同时适用于纵向和横向。但是1个控制器只能在一个肖像中工作。

My app works in both portrait and landscape. But 1 controller should only works in a Portrait.

问题是,当我在横向并推动视图控制器时,新的视图控制器也处于横向状态,直到我旋转它是肖像。然后它应该像是应该是肖像。

The problem is that when I am in landscape and push the view controller the new viewcontroller is in landscape as well until I rotate it to portrait. Then it's stuck in portrait as it should be.

是否可以始终以纵向显示?即使它的父母在风景中推动它?

Is it possible to always make it appear in portrait? Even if its parent is pushing it in landscape?

以下所有代码都没有帮助

All the following code doesn't help

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

此代码一直有效,除非我不是从景观推动如何在iOS 6中强制UIViewController以纵向方向

And this code works until and unless i am not pushing from landscape How to force a UIViewController to Portrait orientation in iOS 6

推荐答案

我通过在ViewDidLoad中添加以下行来解决这个问题

I solved this by adding following lines in ViewDidLoad

UIViewController *c = [[UIViewController alloc]init];
[self presentViewController:c animated:NO completion:nil];
[self dismissViewControllerAnimated:NO completion:nil];

这篇关于从横向视图控制器推动时强制纵向方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆