2011-08-05 102 views
1

我使用IF語句來檢測設備的方向何時發生更改以及何時發生,會顯示一個新視圖,一個肖像,另一個環境。唯一的問題是,如果我從肖像旋轉到風景,並且風景視圖顯示,它並未一直旋轉。它仍然是肖像,它應該是90度。謝謝你的幫助!視圖不能正確旋轉

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
     //portrait 

     self.view = portrait; 


    } else { 
     //landscape 

     self.view = landscape; 

    } 

} 

回答

1

從蘋果爲此here提供示例代碼。

+0

完美,謝謝! –

0

您可能能夠通過willRotateToInterfaceOrientation期間存儲目的地的方向,然後推新視圖之後就didRotateFromInterfaceOrientation解決它。

+0

好吧,那我該怎麼做?類似於self.view = UIInterfaceOrientationPortrait || UIInterfaceOrientationPortraitUpsideDown等?謝謝你的幫助! –