Matt Green
Matt Green

Reputation: 185

UIImagePickerController custom overlay preview taken photo

I'm creating custom camera controls using the UIImagePickerController. The problem I'm having is this:

When the user takes a photo, I would like to show a preview of the photo they have just taken. I have managed to do this by displaying a UIImageView over the camera viewfinder. The only problem is that there is a visible delay before the imageview is shown. Any ideas? My code is shown below

- (void)viewDidLoad
{
   [super viewDidLoad];
   picker = [[UIImagePickerController alloc] init];
   [picker setSourceType:UIImagePickerControllerSourceTypeCamera];
   overlayViewController = [[CameraOverlayViewController alloc] initWithNibName:nil bundle:nil];
   [picker setCameraOverlayView:overlayViewController.view];
   [picker setShowsCameraControls:NO];
   [picker setDelegate:self];
   [self.view addSubview:picker.view];
}

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *img = [info objectForKey:UIImagePickerControllerOriginalImage];
    [overlayViewController.imgView setImage:img];
    [overlayViewController.imgView setHidden:NO];
    return;
}

Upvotes: 0

Views: 1794

Answers (1)

xissburg
xissburg

Reputation: 628

The UIImagePickerController is a subclass of UINavigationController. You can create a custom preview view controller (just a view controller containing an image view and the cancel and use buttons) and push it on the image picker controller.

Upvotes: 2

Related Questions