在我的 iPhone 应用程序中,我使用 PhotoLibrary 中的 UIImagePickerController 拍摄图像。如何获得正确的 imageOrientation 属性?
更新无论如何我都会得到 UIImageOrientationUp
在我的 iPhone 应用程序中,我使用 PhotoLibrary 中的 UIImagePickerController 拍摄图像。如何获得正确的 imageOrientation 属性?
更新无论如何我都会得到 UIImageOrientationUp
Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.
As per the UIImagePickerController Class Reference
Check this question also: Stack over flow link
对名为“image1”的图像使用此方法
[自检ImageOrientaionImage:image1];
方法:
-(void)checkImageOrientaionImage:(UIImage*)image
{
if (image.imageOrientation == UIImageOrientationUp)
{
NSLog(@"portrait");
}
else if (image.imageOrientation == UIImageOrientationLeft || image.imageOrientation == UIImageOrientationRight)
{
NSLog(@"landscape");
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImageOrientation imageOrientation = image.imageOrientation;
}
在您的 didFinishPickingMediaWithInfo 委托方法中编写此代码
UIImage
从信息字典中获取。
然后用这个 UIImageOrientation orient = image.imageOrientation;