开发者

UiImagePickerController - Additional Preview Screen With Overlay

开发者 https://www.devze.com 2023-03-03 12:27 出处:网络
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

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 y开发者_运维技巧et 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..


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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号