在纵向模式下从iPhone点击的图像旋转90度

Sur*_*rma 6 iphone image

我正在横向和纵向模式上传从iphone点击的图像.具有横向模式的图像上传得很好,但问题在于以纵向模式上传的图像.它们旋转了90度.

其他具有纵向模式的图像(不是从iPhone点击)工作正常.

知道为什么会这样吗?

Ale*_*nte 5

在你的代表中:

   - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)

你得到你之后UIImage从"信息"字典键" UIImagePickerControllerOriginalImage",就可以看到imageOrientation财产的形象定位.如果不是您想要在上传之前旋转图像.

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 
Run Code Online (Sandbox Code Playgroud)

UIImage类参考

UIImagePickerController类参考

UIImagePickerControllerDelegate协议参考

第二种选择:

是允许用户编辑图像并获取" UIImagePickerControllerEditedImage" 的图像;

UIImagePickerController" allowsEditing "属性设置为Yes.

在你的委托中,只需从"info"字典中UIImage获取" UIImagePickerControllerEditedImage"键即可.

祝好运.