0

在我的 iPhone 应用程序中,我使用 PhotoLibrary 中的 UIImagePickerController 拍摄图像。如何获得正确的 imageOrientation 属性?

更新无论如何我都会得到 UIImageOrientationUp

4

4 回答 4

0

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

于 2013-08-19T11:11:23.540 回答
0

对名为“image1”的图像使用此方法

[自检ImageOrientaionImage:image1];

方法:

-(void)checkImageOrientaionImage:(UIImage*)image
{

    if (image.imageOrientation == UIImageOrientationUp)
    {
        NSLog(@"portrait");
    }
   else if (image.imageOrientation == UIImageOrientationLeft || image.imageOrientation == UIImageOrientationRight)
    {
       NSLog(@"landscape");
    }

}

于 2013-08-19T11:02:42.860 回答
0
 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
        UIImageOrientation imageOrientation = image.imageOrientation;

    }
于 2013-08-19T10:16:21.197 回答
-1

在您的 didFinishPickingMediaWithInfo 委托方法中编写此代码

UIImage从信息字典中获取。

然后用这个 UIImageOrientation orient = image.imageOrientation;

于 2013-08-19T10:18:30.583 回答