问题
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