在iphone中自定义摄像机视图

时间:2011-06-28 11:56:06

标签: iphone camera

提前致谢。 我想创建一个自定义相机视图的视图。就像这个enter image description here

一样

要在一个视图控制器中执行此操作,我已经创建了另一个视图控制器的实例,在第二个viewcontroller中,我正在创建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)];

实际上这不起作用。这是正确的过程吗?谁能帮我 。

1 个答案:

答案 0 :(得分:2)

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;

晒。