为什么我的图像在纵向模式下运行iOS 6的iPod上被设置为UIImageOrientationRight?

时间:2014-05-05 22:02:26

标签: ios iphone objective-c cocoa-touch uiimagepickercontroller

我的设置是用于测试的:

  • iPod Touch 4th Generation(非自动对焦相机)
  • 运行iOS 6.1.6(此型号的最新版本)
  • App采用最新的Xcode 5.1.1和iOS 7.1构建,但具有向后兼容性,可在iOS 6设备上运行

每当我使用UIImagePickerController使用此设备拍摄肖像照片时,我的返回图片的方向为UIImageOrientationRight。它不应该给我UIImageOrientationUp吗?

以下是我用来打开相机的电话:

- (IBAction)goToCamera
{
    UIImagePickerController *mypicker = [[UIImagePickerController alloc] init];
    mypicker.delegate = self;
    mypicker.allowsEditing = NO;
    mypicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    mypicker.showsCameraControls = YES;
    mypicker.wantsFullScreenLayout = YES;
    [self presentViewController:mypicker animated:YES completion:nil];
}

这是返回委托调用:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *pickedImage = info[UIImagePickerControllerOriginalImage];
    [self dismissViewControllerAnimated:YES completion:nil];

    NSLog(@"%d", pickedImage.imageOrientation);
}

即使我以肖像方式拍摄照片,NSLog也始终显示UIImageOrientationRight。为什么呢?

1 个答案:

答案 0 :(得分:1)

图像方向与界面方向不同。

正如您所发现的那样,相机的原生方向是风景(有意义,这是传统相机的“预期”方向)而不是牺牲实际旋转其他方向拍摄的图像,iOS只是更改方向标签这样它才能正确显示。