提前致谢。
我想用自定义相机视图创建一个视图。

为此,我在一个视图控制器中创建了另一个视图控制器的实例,在第二个视图控制器中,我正在创建UIImagepickerController,如下所示:

-(void)showCamera
{
camController = [[UIImagePickerController alloc]init];
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        camController.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    camController.showsCameraControls = NO;
    camController.navigationBarHidden = YES;
    camController.toolbarHidden = YES;
    camController.wantsFullScreenLayout = NO;
    camController.cameraViewTransform = CGAffineTransformScale(camController.cameraViewTransform, 2.0f, 2.0f);
// Edited
//[self presentModalViewController:camController animated:YES];

}


在第一个视图控制器中:

cam = [[CamController alloc]init];
cam.view.frame = CGRectMake(5, 50, 310, 300) ;
[cam showCamera];
[self.view addSubview:cam.view];
//Edited
 [self.cam presentModalViewController:self.cam.camController animated:NO];
 [self performSelector:@selector(setFrame) withObject:self afterDelay:1.0];
 [self.cam.camController.view setFrame:CGRectMake(10, 50, 300, 250)];


这实际上是行不通的。这是正确的过程吗?谁能帮我 。

最佳答案

sandhya,UIImagePickerController通过名为cameraOverlayView的属性为此具有内置函数。

您可以分配视图,然后

UIImagePicker *camPicker; // alloc camera picker here bla bla bla
CameraView *camview = [[CameraView alloc] initWithNibName:@"CameraView" bundle:nil];
camPicker.cameraOverlayView = camview.view;
camPicker.showsCameraControls = NO;


10-08 07:32