views:

36

answers:

1

Hi!

I'm initializing an UIImagePickerController like this:

    self.cameraController = [[UIImagePickerController alloc] init];

    self.cameraController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    self.cameraController.showsCameraControls = NO;
    self.cameraController.navigationBarHidden = YES;
    self.cameraController.wantsFullScreenLayout = YES;

The problem is that when this is shown, instead of the camera controls, I get a black bar in its place.

How can I make UIImagePickerController.frame take all the screen space?

Thanks!

+1  A: 

The iPhone's camera has a 4:3 aspect ratio whereas the iPhone's screen's aspect ratio is 3:2. Therefore, the live camera picture does not cover the entire screen. If you want to get rid of the black bars, you have to apply a small scaling transform (e.g. 110%) to the camera view.

Ole Begemann
Rather than hard-coding a specific scale factor, use the ratio of the ratios. (screen aspect ratio) / (picture aspect ratio) = scale factor to scale the 4:3 camera image up to fit the 3:2 screen. (Don't hard-code the photo or screen aspect ratios either, of course—get the image's and the screen's sizes, and divide width by height for each of them.)
Peter Hosey
+1 Good suggestion, Peter.
Ole Begemann