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

时间:2011-11-22 15:27:43

标签: iphone camera camera-overlay

我在viewController中显示小型实时相机图像时遇到了很多麻烦。

我原本期望以下代码显示相机显示在100x 100窗口中显示,但它会一直显示全屏!

帮助表示赞赏。

camera = [[UIImagePickerController alloc] init];

UIView *cameraHUD = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
cameraHUD.userInteractionEnabled = YES;

[camera setSourceType:UIImagePickerControllerSourceTypeCamera];
camera.showsCameraControls = NO;
camera.navigationBarHidden = YES;
camera.toolbarHidden = YES;

camera.cameraOverlayView = cameraHUD;
[self presentModalViewController:camera animated:YES];
[self.view bringSubviewToFront:cameraHUD];

1 个答案:

答案 0 :(得分:-1)

您将出现一个新视图,而不是您的实际视图,因此默认情况下,新的UIView具有要填充的contentmode = scale。 你必须添加例如:

[camera setContentMode:UIViewContentModeTopLeft];

但是如果你想做一些很酷的事情,你必须将你的相机视图添加为子视图。 我希望它可以帮到你 再见;)

相关问题