UIImage Picker自动旋转功能突然消失

时间:2009-05-28 13:24:42

标签: rotation uiimagepickercontroller orientation preview

我正在使用UIImagePickerController而没有任何问题。

在我以横向模式拍摄照片之前,预览中的图片(当按钮重新拍摄和使用照片存在时)总是自动旋转,以便在肖像中正确显示模式。

但现在当我使用UIImagePickerController时,预览模式不再旋转图片了。

我在哪里可以激活或取消激活此模式?

这是我的代码:

- (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];
}

我真的需要至少了解正在发生的事情,所以即使不是解决方案,任何帮助都会非常感激!

谢谢大家!

1 个答案:

答案 0 :(得分:1)

一种可能性是你需要打电话

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];