在纵向模式下从iPhone点击的图像旋转90度 [英] image clicked from iPhone in Portrait mode gets rotated by 90 degree
问题描述
我正在横向和纵向模式上传从iphone点击的图像。
具有横向模式的图像上传得很好,但问题在于以纵向模式上传的图像。它们被旋转了90度。
I am uploading an image clicked from iphone both in landscape and portrait mode. The image with landscape mode is uploaded fine but the issue is with the image uploaded with portrait mode. They gets rotated by 90 degree.
其他带有肖像模式的图像(不是从iPhone点击)也能正常工作。
Also other images with portrait mode(not clicked from iPhone) works fine.
知道为什么会这样吗?
推荐答案
在你的代表中:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
从info字典中获取 UIImagePickerControllerOriginalImage
后的 UIImage
,您可以通过imageOrientation属性查看图像方向。如果不是你想在上传之前旋转你的图像。
After you get your UIImage
from "info" dictionary for the key "UIImagePickerControllerOriginalImage
" ,You can see the image orientation by imageOrientation property. If is not like you want just rotate your image before you upload it.
imageOrientation
The orientation of the receiver’s image. (read-only)
@property(nonatomic, readonly) UIImageOrientation imageOrientation
Discussion
Image orientation affects the way the image data is displayed when drawn. By default, images are displayed in the "up" orientation. If the image has associated metadata (such as EXIF information), however, this property contains the orientation indicated by that metadata. For a list of possible values for this property, see "UIImageOrientation."
Availability
Available in iOS 2.0 and later.
Declared In
UIImage.h
UIImagePickerControllerDelegate Protocol Reference
第二个选项:
是否允许用户编辑图像并获取 UIImagePickerControllerEditedIm的图像年龄
;
Is to allow user to edit your image and get the image for "UIImagePickerControllerEditedImage
";
设置 UIImagePickerController
allowEditing 属性是
。
在您的委托中,只需从info字典中获取 UIImage
表示 UIImagePickerControllerEditedImage
键。
In your delegate just get from the "info" dictionary the UIImage
for the "UIImagePickerControllerEditedImage
" key.
祝你好运。
这篇关于在纵向模式下从iPhone点击的图像旋转90度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!