0
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(dragger.frame.origin.x, dragger.frame.origin.y,dragger.frame.size.width, dragger.frame.size.height)] ;
imgView.image = dragger.image;  
overlayView = [[UIView alloc] initWithFrame:CGRectMake(dragger.frame.origin.x,dragger.frame.origin.y,dragger.frame.size.width, dragger.frame.size.height)];
[overlayView addSubview:imgView];

//open the camera

self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraOverlayView=overlayView;  
[self.navigationController presentModalViewController:self.picker animated:YES];

This works fine in portrait mode but the overlay image does not change while in the landscape mode.

How can i achieve this as I need help on this?

Larry Morries
  • 669
  • 7
  • 17
vinay
  • 1,276
  • 3
  • 20
  • 34
  • I too faced same issue. This link helped me to resolve the issue. http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload – Naveen Thunga Oct 14 '11 at 05:57

1 Answers1

0

you need to register for change in orientation... like this

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:@"UIDeviceOrientationDidChangeNotification" 
                                               object:nil];

and then write this function in the same class....

- (void) orientationChanged:(NSNotification *)notification{  
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

    //do stuff

    if (orientation==UIDeviceOrientationPortrait) {
        imagePickerController.cameraOverlayView = portraitImageView;

    }

    else if(orientation==UIDeviceOrientationLandscapeLeft)
    {

        imagePickerController.cameraOverlayView = landscapeImageView;

    }

}
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115