我的应用程序中唯一允许的方向是横向。我在 target > summery 下的项目属性中强制执行此操作,并且只允许在shouldAutorotateToInterfaceOrientation
问题是当我水平握住手机(横向)拍照时,照片将以横向拍摄,而 UI 保持纵向模式。
这意味着在横向模式下,我得到一个 3264 x 2448 的宽图像,而不是在纵向模式下得到的高大图像 (2448 x 3264)。
接下来用户可以裁剪图像,但如果图像是在横向模式下拍摄的,我会得到非常难看的拉伸图像。添加边框或将 UI 切换为横向不是一种选择。
即使手机水平握住(横向模式) ,有没有办法强制UIImagePickerController
以纵向尺寸拍照?
UIImagePickerController
我使用以下设置初始化:
imagePicker =[[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
imagePicker.showsCameraControls = NO;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.wantsFullScreenLayout = YES;
imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform,CAMERA_TRANSFORM, CAMERA_TRANSFORM);
imagePicker.navigationBarHidden = YES;
imagePicker.toolbarHidden = YES;
[self presentModalViewController:imagePicker animated:NO];
imagePicker.cameraOverlayView = self.cameraOverlay;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;