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