2010-03-12 43 views
0

根據我的代碼時,我的設備是使用在風景如何旋轉至當前的方向?

當我在pushViewController UIDeviceOrientationPortrait它將

自動顯示。

我需要我的設備旋轉爲縱向,然後旋轉爲橫向,

那麼它會出現在橫向模式。

我怎樣才能旋轉到取向當前使用私有API(setOrientation)?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIDeviceOrientationPortrait) || 
      (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
} 

回答

2

嘗試設置狀態欄方向:

UIApplication *app = [UIApplication sharedApplication]; 
[app setStatusBarOrientation: UIInterfaceOrientationLandscape]; 
[app setStatusBarHidden: NO animated: YES]; 

您可以獲得當前設備的方向是這樣的:

[UIDevice currentDevice].orientation 
+0

感謝普拉門Dragozov – RAGOpoR

+0

它沒有回答我的問題。 – RAGOpoR