1

根据我是直接从回调中的相机获取图像还是从相机胶卷中选择图像,我得到的结果不一致。

UIImagePickerControllerDelegate回调方法中,无论照片如何拍摄,UIImage.imageOrientation都会出现。UIImageOrientationRight

当从相机胶卷上读取它时,会出现一张风景照片(向左转),UIImageOrientationUp同时出现一张人像照片UIImageOrientationRight

如何在这两种情况下可靠地获取相机方向?

4

3 回答 3

3

我将此发布到 Apple 论坛,并得到了解释:

“相机实际上是横向原生的,所以当你在风景中拍照时你会向上或向下,当你在纵向拍照时你会向左或向右(取决于你拿着设备的方式)。”

看:

https://devforums.apple.com/message/301160#301160

谢谢:

https://devforums.apple.com/people/Rincewind

于 2010-09-23T17:55:50.283 回答
0

拍完照片后,我尝试了 imageOrientation 属性,这很有趣,因为我的方向值搞砸了。上为左,下为右,左为下,右为上,例如,如果我握住 iPhone“上”(正常位置),则 imageOrientation 为“UIImageOrientationRight”。

- (void)imagePickerController:(UIImagePickerController *)picker
  didFinishPickingImage:(UIImage *)image
      editingInfo:(NSDictionary *)editingInfo {
    switch (image.imageOrientation) {
      case UIImageOrientationUp: //Left
       break;
      case UIImageOrientationDown: //Right
       break;
      case UIImageOrientationLeft: //Down
       break;
      case UIImageOrientationRight: //Up
       break;
      default:
       break;
     }
}

目前我正在使用针对 iOS 3.1 的 4.1 SDK GM (xcode_3.2.4_and_ios_sdk_4.1_gm_seed)

于 2010-09-08T16:04:27.280 回答
-1

我在某处读到UIImagePickerController 没有打开监听硬件方向事件,所以你可能需要调用

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

在您自己的应用程序中捕获图像之前。我将自己尝试测试这个,所以我希望它有效!

于 2009-06-25T16:54:41.080 回答