2012-01-29 58 views
0

如何手动调用shouldAutorotateToInterfaceOrientation?Iphone:手动更改方向

此功能的内容有开/关标志,所以当我改变这个标志时,我需要旋转屏幕。

实施例:

  1. 禁用标志
  2. 倾斜电话在水平位置。 shouldAutorotateToInterfaceOrientation调用并返回false
  3. 启用标志:shouldAutorotateToInterfaceOrientation必须被调用。如何调用它?

回答

5

如果你的目标iOS 5中,您可以拨打

[UIViewController attemptRotationToDeviceOrientation]

,它将调用shouldAutorotateToInterfaceOrientation:与设备当前的方向,如果该方法返回YES将旋转的接口。

+0

谢谢,但我需要iOS 3的支持。任何其他想法如何实现它? – DmitryR 2012-01-29 15:33:25

+1

我正在寻找这样的10年! THX,THX,THX! – lennartk 2013-08-22 14:18:04