iphone:在窗口中显示小的实时摄像机图像

时间:2011-11-21 21:43:55

标签: iphone camera subview

我想调用相机并在嵌入标准viewController的小预览窗口(类似于下面)中显示实时图像。下面的代码创建了实时缩小的摄像机图像,但我看不到NIB文件中的其他对象。思想赞赏。

enter image description here

    imagePicker = [[UIImagePickerController alloc] init];
//Setting the control source type as the Camera device.
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

//Camera display is off
imagePicker.showsCameraControls = NO;
imagePicker.navigationBarHidden = YES;

//Picking only the rear camera.
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;

//Turning the camera flash off.
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;

// Make camera view partial screen:
imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform, 0.5, 0.5);  

// add subView
[self.view addSubview:imagePicker.view];
[imagePicker viewWillAppear:YES];
[imagePicker viewDidAppear:YES];

// Show the picker:
[self presentModalViewController:imagePicker animated:YES]; 

1 个答案:

答案 0 :(得分:1)

如果不运行代码,您似乎正在更改实时图像,而不是视图的大小。因此,原始的全尺寸视图显示在其他视图的顶部。

您是否尝试过使用camerOverlayView在实时图像上叠加viewcontrollers视图?

  

cameraOverlayView   自定义视图显示在默认图像选择器界面之上。

     

@property(非原子,保留)UIView * cameraOverlayView讨论你   可以使用叠加视图在顶部显示自定义视图层次结构   默认的图像选择器界面。图像选择器分层你的   自定义叠加视图位于其他图像选择器视图和   将其相对于屏幕坐标定位。如果你有   默认相机控件设置为可见,包含透明度   进入你的视图,或定位它以避免模糊底层   内容。