1

I am having a great deal of trouble displaying at small, live camera image in a viewController.

I would have expected the following code to show camera display to appear in a 100x 100 window, but it keeps appearing full screen!

Help appreciated.

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];
Jeremy
  • 883
  • 1
  • 20
  • 41
  • You are displaying the camera viewController modally (fullscreen). – Till Nov 22 '11 at 16:56
  • I think the issue is you are confusing what the overlay does. The overlay is a skin over the camera view. So it will always be full screen, especially if you present it modally. If you use the previous code for the camera view, and then use the overlay to show any of the controls you need then it should work. – JamesSugrue Nov 23 '11 at 22:19

1 Answers1

-1

You are present a new view instead of your actual view, so by default a new UIView has contentmode= scale to fill. You have to add for example something like:

[camera setContentMode:UIViewContentModeTopLeft];

But if you want do something cool you have to add your Camera View as subview. I hope it can help you bye ;)

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
derfel83
  • 23
  • 2
  • Thanks derfel & Justin. I added [cameraHUD setContentMode:UIViewContentModeTopLeft]; to the method above but it had no affect whatsoever. Still displaying camera full screen. Can you please advise how I add as a small subbview? – Jeremy Nov 22 '11 at 16:42
  • oh, you have to add your view as subview: `[self.view addSubview:cameraHUD];` or: you have to do a new blank view and inside that you have to add your new view as subview. – derfel83 Dec 13 '11 at 08:20