iPad方向改变问题 [英] iPad orientation change issue

查看:83
本文介绍了iPad方向改变问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序在支持方向更改时在iPad上运行时会显示一些奇怪的行为。

My iPhone application is displaying some odd behavior when run on the iPad with respect to supporting orientation changes.

该应用程序以视图控制器启动(称之为视图A为了参数)和导航控制器,并且shouldAutorotateToInterfaceOrientation仅为肖像返回YES。在导航控制器上,我按下一个视图控制器(视图B),它也仅为肖像返回YES。然后,我将另一个视图控制器(视图C)推到支持所有旋转的导航控制器上,并根据要旋转的方向调整屏幕上的项目。

The app starts up with a view controller (call it view A for the sake of argument) and navigation controller, and shouldAutorotateToInterfaceOrientation is returning YES for portrait only. Onto the navigation controller, I push a view controller (view B) that also returns YES for portrait only. Then, I push another view controller (view C) onto the nav controller that supports all rotations and adjusts the items on screen based on the orientation to rotate to.

当这个在iPhone模拟器和设备上运行,如果您在视图C上旋转到横向,然后点击后退按钮返回到视图B,它会做正确的事情并将视图B切换回纵向模式。 (在模拟器中,它甚至可以自动将模拟器旋转回到肖像。)

When this is run on the iPhone simulator and device, if you rotate to landscape on view C and then tap the back button to return to view B, it does the right thing and shifts view B back to portrait mode. (In the simulator, it even rotates the simulator back to portrait automagically.)

我遇到的问题是,当我这样做时,完全相同的事件序列iPad模拟器和设备,出现的视图B没有旋转回纵向,导航控制器仍然显示视图C的信息。然后,我点击后退按钮,视图保持不变,但导航控制器显示正常对于视图B(但仍处于横向模式)。然后,如果我再次点击后退按钮,视图B会出现在视图B导航栏项目下,最后再次点击后退我会看到带有导航栏A项目的视图A.

The problem I am experiencing is that, when I do this exact same sequence of events on the iPad simulator and device, the view B that appears is not rotated back to portrait, and the nav controller still shows the information for view C. Then, I tap on the back button, and the view stays the same but the nav controller shows normal for view B (but all still in landscape mode). Then, if I tap the back button again, view A appears under the view B nav bar items, and finally tapping back again puts me on view A with nav bar A items.

如果我在iPad上查看B并开始旋转,那么应该在没有触发的情况下使用NO来触发,直到我达到纵向模式,然后全部恢复正常。

If I go to view B on the iPad and start to rotate around, shouldAutorotateToInterfaceOrientation fires with NO until I reach portrait mode, and then all returns to normal.

应用程序正在使用最新发布的iPhone SDK版本构建,并具有如下构建设置:iPhone模拟器4.0的基本SDK,iPhone的目标设备系列,iPhone OS 3.1.3的iPhone OS部署目标。

The application is being built with the latest released version of the iPhone SDK, and has build settings as follows: Base SDK of iPhone Simulator 4.0, Targeted Device Family of iPhone, iPhone OS Deployment Target of iPhone OS 3.1.3.

任何想法?

推荐答案

Apple声明:


案例: UITabBarController或UINavigationController中的所有子视图控制器都不同意公共方向集。

Case: All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set.

响应:为了确保所有子视图控制器都能正确旋转,你就可以了对于表示每个选项卡或导航级别的每个视图控制器,st实现shouldAutorotateToInterfaceOrientation。每个人必须就旋转发生的方向达成一致。也就是说,对于相同的方向位置,它们都应该返回YES。

Response: To make sure that all your child view controllers rotate correctly, you must implement shouldAutorotateToInterfaceOrientation for each view controller representing each tab or navigation level. Each must agree on the same orientation for that rotate to occur. That is, they all should return YES for the same orientation positions.

http://developer.apple.com/iphone/library/qa/qa2010/qa1688.html

您可以在导航控制器中设置设备方向,而不是在单个视图中设置。然后,您可以检查堆栈中的哪个视图并根据结果进行旋转。通过这种方式,导航控制器也可以处理所有方向。

You may be able to set device orientation within the navigation controller instead of within individual views. Then you could check which view is on the stack and rotate based on the result. In this way, the navigation controller handles all orientation as well.

这篇关于iPad方向改变问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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