1

in my iPhone application, I am using metaio sdk with UnfieyeMobileViewController. I have customized the view to show the camera view on the EAGLView component, and its works fine. The issue the when rotate the device, the camera orientation is not changing. And also, the captured image is showing upside down. Here is my code, please check:

In 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;
}
Mithuzz
  • 1,091
  • 14
  • 43

0 Answers0