从横向视图控制器中纵向推动视图控制器 [英] Push a view controller in portrait from a view controller that's in landscape

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

问题描述

我有一个UITableViewController,可以纵向和横向工作。从这个控制器我将另一个视图控制器推到导航控制器上。这个新的viewController只是肖像。

I have a UITableViewController that works in both portrait and landscape. From this controller I push another view controller on to the navigation controller. This new viewController is portrait only.

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

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?

更新:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


推荐答案

在你的 viewWillAppear:使用以下代码:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

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

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