views:

604

answers:

1

I was using UIImagePickerController without any problem.

Before when I was taking a picture in the landscape mode, the picture in the Preview (when the buttons Retake and Use Photo were present) was always automatically rotated so as to appear correctly in the portrait mode.

But now when I use the UIImagePickerController the preview mode does not rotate the picture anymore.

Where can I activate or desactivate this mode?

Here is my code

- (IBAction)getCameraPicture{



    //Create an UIImagePickerController to be able to take a picture
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;

    picker.allowsImageEditing = NO;
    [self presentModalViewController:picker animated:YES];
    [picker release]; 


- (IBAction)selectExistingPicture{

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;//Here is specified the fact that the picker source is the library
        [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing photo library" message:@"Device does not support a photo library" delegate:nil cancelButtonTitle:@"Drat!" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

    int imageCase=0;
    UIImage *imageSaved=rotateImage(image);
    UIImage* imageNormal =scaleImage(imageSaved,imageCase);



    imageView.image = imageNormal;



    [picker dismissModalViewControllerAnimated:YES];

}



- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

    [picker dismissModalViewControllerAnimated:YES];
}

I really need to at least understand what is happening so any help would be really appreciated even if it is not the solution!

Thanks folks!

A: 

one possibility is that you need to call

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
David Maymudes