在iPhone上将方向设置为纵向

在iPhone上将方向设置为纵向

问题描述:

我有一个包含一个登录名,3个表和一个图像的应用程序.

I have an application that consists of a login, 3 tables, and then an image.

您可以将图像旋转到横向模式,但是我想要做的是当按下后退"按钮并且应用程序返回到上一屏幕时,我是要自动旋转以提供人像视图的应用程序.

You can rotate the image to landscape mode but what I want to be able to do is when the 'back' button is pushed and the app returns to the previous screen, I was the app to automatically rotate to give a portrait view.

有什么办法吗?

如果以前的视图控制器仅支持纵向(请参见 shouldAutorotateToInterfaceOrientation:),则它应该自动旋转.

If the previous view controller only supports portrait (see shouldAutorotateToInterfaceOrientation:) then it should automatically rotate.

如果先前的视图控制器支持横向,但如果它最初是纵向的,则希望将其旋转为纵向,则可以通过更改向后导航时应返回的 shouldAutorotateToInterfaceOrientation:来强制使用横向视图.我不推荐这个.它的UI不一致(弄清楚正在导航的内容有点繁琐).

If the previous view controller supports landscape but you want it to rotate to portrait if it was originally in portrait, you can probably force it by changing what shouldAutorotateToInterfaceOrientation: returns when navigating back. I wouldn't recommend this; it's inconsistent UI (and it's a bit tedious to figure out what navigation is going on).

有多种方法可以设置视图控制器的界面方向(-[UIDevice setOrientation:] 会尝试触发自动旋转),但是您就进入了私有API和潜在拒绝的领域

There are various ways to set the view controller interface orientation (-[UIDevice setOrientation:] will attempt to trigger an autorotation), but then you're into the realm of private APIs and potential rejection.