UnifeyeMobileViewController glView相机视图在iPhone中不旋转

时间:2012-07-17 05:56:49

标签: iphone ios camera orientation eaglview

在我的iPhone应用程序中,我正在使用带有UnfieyeMobileViewController的metaio sdk。我已经自定义视图以在EAGLView组件上显示摄像机视图,并且其工作正常。旋转设备时,相机方向不变的问题。而且,捕获的图像显示为颠倒。这是我的代码,请检查:

在ViewDidAppear中:

UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;    
[self willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:0];
    [super viewDidAppear:animated];

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    // adjust the rotation based on the interface orientation
    switch (interfaceOrientation) {
        case UIInterfaceOrientationPortrait:
            self.glView.transform = CGAffineTransformMakeRotation(0);
            break;

        case UIInterfaceOrientationPortraitUpsideDown:
            self.glView.transform = CGAffineTransformMakeRotation(M_PI);
            break;

        case UIInterfaceOrientationLandscapeLeft:  
            self.glView.transform = CGAffineTransformMakeRotation(M_PI_2);
            break;

        case UIInterfaceOrientationLandscapeRight:
            self.glView.transform = CGAffineTransformMakeRotation(-M_PI_2);
            break;
    }   

    // make sure the screen bounds are set correctly
    CGRect mainBounds = [UIScreen mainScreen].bounds;

    if( UIInterfaceOrientationIsLandscape(interfaceOrientation) )
    {
        int width = mainBounds.size.width;
        int height = mainBounds.size.height;
        mainBounds.size.width = height;
        mainBounds.size.height = width;
    }

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // for iPhone the aspect ratio does not fit, so let's correct it
        if( UIInterfaceOrientationIsLandscape(interfaceOrientation) )
        {
            mainBounds.size.height = 360;   // because our renderer is a bit larger
            mainBounds.origin.y = -20;
        }
        else
        {
            mainBounds.size.width = 360;   // because our renderer is a bit larger
            mainBounds.origin.x = -20;            
        }
    }

    self.glView.frame = mainBounds;
}

0 个答案:

没有答案