1

The latest "Yelp" app provides "Add Business Photo" functionality. After taking a photo the preview screen is displayed as usual. However tapping the "use" button displays what appears to be the same preview screen with an overlay containing buttons and a textfield to enter a caption. I've read that the way to display an overlay on the preview screen "ONLY" is as follows:

- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
   if (!viewController)
   return;

   UIView* controllerViewHolder = viewController.view;
   UIView* controllerCameraView = [[controllerViewHolder subviews] objectAtIndex:0];
   UIView* controllerPreview = [[controllerCameraView subviews] objectAtIndex:0];
   [controllerCameraView insertSubview:self.overlayView aboveSubview:controllerPreview];
}

I've yet to get this to work :) however I'm now debating on what approach to use in order to display the preview screen twice ie. once normally and then afterward with overlay?

I dont know the ins and outs of UIImagePickerController yet and and I'm wondering if its possible to insert the overlay above the preview and re-display the preview after the preview has been displayed (not sure if thats possible) or create and display a entirely new view (copy of preview with overlay applied)? (not sure how I would do that either).

Thanks in advance for your input..

memmons
  • 40,222
  • 21
  • 149
  • 183
imobilizer
  • 161
  • 1
  • 13

1 Answers1

2

The UIImagePickerController is a navigation controller. That means you can push things on and off of the view controller stack controlled by the image picker. When you get the imagePickerController:didFinishPickingMediaWithInfo: notification, just push another view onto the image picker stack like this.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   NSURL *imageURL = [info objectForKey:UIImagePickerControllerMediaURL];
   MyCustomPreviewController *customPreview = [[MyCustomPreviewController alloc] initWithImageURL:imageURL];

   [picker pushViewController:customPreview animated:YES];
}
Randall
  • 14,691
  • 7
  • 40
  • 60