在推之前旋转视图? [英] Rotate a view prior to pushing?

查看:45
本文介绍了在推之前旋转视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个视图A和B.A推到B,B弹出回到A.在A中,使用"shouldAutorotateToInterfaceOrientation"将旋转限制为Portrait和PortraitUpsideDown.

I have two views A and B. A pushes to B, and B pops back to A. In A, using "shouldAutorotateToInterfaceOrientation" I limit rotation to Portrait and PortraitUpsideDown.

在B中,我将旋转限制为LandscapeLeft/Right.

In B I limit the rotation to LandscapeLeft/Right.

但是,当我按视图B时,无论设备的初始方向如何,视图B也会显示人像",直到我旋转设备.从那时起,它会自动旋转到LandscapeLeft/Right.

However, when I push to view B, regardless of the initial orientation of my device, view B also shows up Portrait until I rotate my device. From then on, it auto rotates to LandscapeLeft/Right like it should.

到目前为止,我所读的所有内容都谈到了shouldAutorotateToInterfaceOrientation,但是我正确地设置了该设置(至少我认为是这样).

Everything Ive read so far talks about shouldAutorotateToInterfaceOrientation, but I have that setup correctly (at least I think I do).

如何使视图B始终从横向开始?

How can make view B always start in Landscape?

谢谢.

推荐答案

使名为B的视图控制器始终从横向启动的最简单方法是以模态显示它,而不是将其推送到导航控制器.这似乎是YouTube应用旋转界面的方法.

The easiest way to make your view controller named B always start in landscape is to present it modally, instead of pushing it to your navigation controller. This seems to be the method the YouTube app uses to rotate the interface.

B *nextVC = [[B alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:nextVC animated:YES];

如果您绝对需要推送视图,则可以执行以下操作:

If you absolutely need to push the view you can do something like this:

B *nextVC = [[B alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:nextVC animated:NO];
UIViewController *cont = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:cont animated:NO];
[cont dismissModalViewControllerAnimated:NO];

信不信由你实际上会产生很好的效果.

Believe it or not it actually produces a nice effect.

这篇关于在推之前旋转视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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