Melanie
Melanie

Reputation: 21

iOS full screen camera overlay

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

Upvotes: 2

Views: 1664

Answers (0)

Related Questions