didFinishPickingMediaWithInfo orientation issue

蹲街弑〆低调 提交于 2020-01-16 19:01:28

问题


i'm trying to manage image rotation in imagePickerController:didFinishPickingMediaWithInfo, but after several attempts, I did not find any solutions. My last try is:

-(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...
    }

I can't and I don't want to use JPEGRepresentation. I need to rotate my photo by 180° when iPad is in specific position.

Any idea?


回答1:


have a Look at this: http://www.catamount.com/blog/1015/uiimage-extensions-for-cutting-scaling-and-rotating-uiimages/

Just call

UIImage *rotatedImage = [originalImage imageRotatedByDegrees:180.0];

Source




回答2:


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

For 180 deg rotation.



来源:https://stackoverflow.com/questions/16413833/didfinishpickingmediawithinfo-orientation-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!