Search code examples
iphoneorientationlandscapecamera-overlay

Camera overlayview not change landscape orientation(Left and Right) in iPhone4?


I have customized the camera with custom buttons(UIButton) by overlay view. My iPhone application will run only in Landscape mode(Left and Right). Now, my camera overlay view change it's orientation left and right perfectly in iPhone 3GS but not run clearly in iPhone4. In ios5 if i launch the camera with overlay view in landscapemode(Right/Left) it launching perfectly but, if i change the orientation to (Right -> Left / Left -> Right) the overlay view not changing perfectly the frame size of the UIView(CameraOverlayView),UIButton frame sizes are changing. How can i fix it? Please help me to fix this problem. I hope you my friends fix my problem. Thanks in advance. Here i have attached my code that i used.

  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

if(orientation == UIDeviceOrientationLandscapeLeft)
{
    CGAffineTransform transform = self.view.transform;
    transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
    imgpicker.cameraOverlayView.transform = transform;
    NSLog(@"Orientation Landscape Left");
} 
else if(orientation == UIDeviceOrientationLandscapeRight)
{
    imgpicker.cameraOverlayView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, 117.81);
    NSLog(@"Orientation Landscape Right");
}

This code works good in iPhone#GS(ios4) but not working good in iPhone4(ios5). Can anyone please help me to fix this problem?


Solution

  • Thank you my friends. I have solved this issue by myself. I just set the bounds to UIView so it covers full view on Camera OverlayView and also i have tried above code that i mentioned in my question.

         cameraview.bounds = CGRectMake(0.0, 0.0, 480.0f, 320.0f); 
    

    And so i have checked this code at beginning of Camera launch,

    UIInterfaceOrientation orientation= [[UIApplication sharedApplication] statusBarOrientation];
        if (orientation == UIInterfaceOrientationLandscapeLeft) 
        {
            imgpicker.cameraOverlayView.transform = CGAffineTransformRotate(CGAffineTransformIdentity,117.81);
        }
        else if (orientation == UIInterfaceOrientationLandscapeRight)
        {        
            CGAffineTransform transform = self.view.transform;
            transform = CGAffineTransformRotate(transform, (M_PI/2.0));
            imgpicker.cameraOverlayView.transform = transform;
        } 
    

    After this i was check this condition in UIDeviceOrientation Notification also. Now, my app working charm. Thanks.