2

I am new to objective-c and have been searching for an answer to this question for a while...

I am creating a photo-sharing app and I want the camera to be full-screen. I have used the following code to hide the default camera overlay and create my own, and make the camera full-screen. On the next screen, I want to display the image captured as full-screen again, but the image is getting collapsed sideways.

Setting the camera overlay:

-(void)loadCamera {
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePicker.delegate = self;
self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.imagePicker.showsCameraControls = NO;

self.overlayIV = [[WAUCameraOverlayView alloc]initWithFrame:self.imagePicker.cameraOverlayView.frame];

[self.imagePicker.cameraOverlayView addSubview:self.overlayIV];

CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
self.imagePicker.cameraViewTransform = translate;

CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
self.imagePicker.cameraViewTransform = scale;

[self presentViewController:self.imagePicker animated:YES completion:nil];

}

The above code works great and makes the camera full-screen with my custom overlay. Then, this block of code gets executed:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self.overlayIV removeFromSuperview];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

}

I pass "image" to the next screen and initialize it to the size of the screen, but it gets stretched... any way to save/display the image captured from the full-screen camera in the exact ratio and size?

EDIT: The code I use to display the image is:

UIImageView *capturedImageView =[[UIImageView alloc]initWithFrame:self.frame];
capturedImageView.image = aImage;
    capturedImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:capturedImageView];

I want the image to be the size of the screen, and the same ratio/aspect as it was captured in the camera

Melanie
  • 21
  • 3
  • Can you show the code you use to size and display the image on the next screen? I'm assuming you are using a `UIImageView`? Your problem may be solved by changing the `contentMode` of your image view to `UIViewContentModeScaleAspectFit`. – Dima Aug 11 '14 at 23:05
  • @Dima Thanks for your suggestion! Unfortunately I tried that and it squished the image more... I want to change the actual image to be the same exact image that the user saw in the camera view (because I am going to store the image and don't want to continually deal with formatting the UIImageView) – Melanie Aug 12 '14 at 17:49
  • I might be a little late to the party, but have you tried removing your overlays and simply doing a screen shot? – Robert Bentley Jul 25 '16 at 03:30

0 Answers0