2012-01-29 57 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