更改UIDeviceOrientation时出现奇怪的行为

时间:2011-08-29 12:59:21

标签: iphone objective-c uideviceorientation

以下是我改变方向时所做的事情......

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown))
    {    
        [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"auto_main_hor.png"]]];
        [UIView commitAnimations];

    } else if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight))
    {
        [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"auto_main_vert.png"]]];
    } 
}

当我将设备急剧旋转180度时,我得到了一些错误的显示?我该如何解决?

1 个答案:

答案 0 :(得分:1)

请注意,UIInterfaceOrientationUIDeviceOrientation不是一回事。您正在使用设备方向,您应该使用界面方向。