0

在我的应用程序中,我使用相机拍照,并且我想使用图像作为相机上的叠加层。仅当我的应用程序处于横向模式时,相机才应显示横向。我将 UIImagePicker 添加为视图的子视图,并且我正在使用下面的代码将其更改为横向模式

CGAffineTransform transform=imgPicker.view.transform;
transform=CGAffineTransformRotate(transform, -90*M_PI/180);
transform=CGAffineTransformTranslate(transform, -52, -47);
[imgPicker setCameraViewTransform:transform];

当我添加任何 UIImageView 作为相机的叠加层时,图像视图并没有添加为横向。它添加了肖像。

这是我的代码:

picker=[[UIImagePickerController alloc] init];
picker.delegate=self;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;

[picker setCameraFlashMode:UIImagePickerControllerCameraFlashModeOff];
[self.view addSubview:picker.view];
picker.view.frame=CGRectMake(0, 0, 480, 320);
picker.cameraOverlayView.frame=picker.view.frame;
CGAffineTransform transform=picker.view.transform;
transform=CGAffineTransformRotate(transform, -90*M_PI/180);
transform=CGAffineTransformTranslate(transform, -52, -47);
[picker setCameraViewTransform:transform];
[picker setWantsFullScreenLayout:YES];
[picker shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 120, 120)];
theView.backgroundColor = [UIColor yellowColor];
[picker setCameraOverlayView:theView];

请告诉我我在哪里做错了提前谢谢

4

0 回答 0