我的设置是用于测试的:
每当我使用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
。为什么呢?
答案 0 :(得分:1)
图像方向与界面方向不同。
正如您所发现的那样,相机的原生方向是风景(有意义,这是传统相机的“预期”方向)而不是牺牲实际旋转其他方向拍摄的图像,iOS只是更改方向标签这样它才能正确显示。