2010-02-20 59 views
1

您好我有這樣的一段代碼...iPhone - 界面方向顛倒?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return YES; 
} 

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){ 
    // WTF, this runs when I change to Landscape 
    } else { 
    // this runs when I change to Portrait??? shouldn't it be the contrary? 
    } 
} 

正如你看到的,代碼在運行相反,我的意思是,部分時,我改變了應該運行設備到肖像,代碼的風景部分運行,反之亦然。

當我打開設備時,self.view旋轉。

是這個UIInterfaceOrientationIsPortrait測試接口在旋轉之前的方式還是我錯過了什麼?

感謝您的任何幫助。

回答

6

請注意,該方法被命名爲didRotate InterfaceOrientation,所以自然interfaceOrientation參數包含舊的方向,而不是新的方向。

+0

ahhh ....顯然!我從來沒有注意到名字中的FROM ......哈哈。謝謝。 – SpaceDog 2010-02-20 16:20:36