didFinishPickingMediaWithInfo方向问题

时间:2013-05-07 07:46:09

标签: ios objective-c xcode ipad uiimage

我正在尝试在imagePickerController:didFinishPickingMediaWithInfo中管理图像轮换,但经过多次尝试后,我找不到任何解决方案。我的最后一次尝试是:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

        // load the storyboard by name
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[ApplicationSupport getStoryBoardName] bundle:nil];
        UploadViewController *uploadView = [storyboard instantiateViewControllerWithIdentifier:@"ViewUploadFile"];

        UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
        NSDictionary *metadataImage = [info valueForKey:UIImagePickerControllerMediaMetadata];

        uploadView.imageToUpload = image;

        if([[metadataImage objectForKey:@"Orientation"] intValue] == 3) {
            UIImage *imageRotated = [UIImage imageWithCGImage:[image CGImage] scale:[image scale] orientation:UIImageOrientationDown];
            uploadView.dataToUpload = UIImagePNGRepresentation(imageRotated);
        } else {
            uploadView.dataToUpload = UIImagePNGRepresentation(image);
        }

        // ETC...
    }

我不能,我不想使用JPEGRepresentation。当iPad处于特定位置时,我需要将照片旋转180°。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

看看这个:http://www.catamount.com/blog/1015/uiimage-extensions-for-cutting-scaling-and-rotating-uiimages/

致电

UIImage *rotatedImage = [originalImage imageRotatedByDegrees:180.0];

Source

答案 1 :(得分:0)

UploadView.DataToUpload = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation:UIImageOrientationDown];

180度旋转。