Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok I managed to put this together myself. Not really sure how to use a transition method, but I needed to duplicate the view in the same location and then blow it up.</p> <p><a href="http://screencast.com/t/MLTuGkIYh">http://screencast.com/t/MLTuGkIYh</a></p> <p>So in my cell that contains the big image I hook up both the pinch and tap gesture recognizers.</p> <pre><code> self.imageView.contentMode = UIViewContentModeScaleAspectFit; self.imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); UIPinchGestureRecognizer *pinchGesture = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)] autorelease]; UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)] autorelease]; tapGesture.numberOfTapsRequired = 2; self.imageView.userInteractionEnabled = YES; self.imageView.multipleTouchEnabled = YES; [self.imageView addGestureRecognizer:pinchGesture]; [self.imageView addGestureRecognizer:tapGesture]; [cell.contentView addSubview:self.imageView]; </code></pre> <p>and then here's the rest of the code. Basically when I recognized the gesture (and for pinching, make sure its finished) I place the duplicate view in the same exact location (gained via the convertRect stuff), and then animate its frame and background color. When returning from it, I do the inverse.</p> <pre><code>- (void)handlePinchGesture:(id)sender { if (((UIPinchGestureRecognizer *)sender).state == UIGestureRecognizerStateEnded) { if(((UIPinchGestureRecognizer *)sender).view == self.imageView) { if (((UIPinchGestureRecognizer *)sender).scale &gt; 1) { [self showFloorPlanFullScreen]; } } else { if (((UIPinchGestureRecognizer *)sender).scale &lt; 1) { [self closeFloorPlanFullScreen]; } } } } - (void)handleTap:(id)sender { if (((UITapGestureRecognizer *)sender).view == self.imageView) { [self showFloorPlanFullScreen]; } else { [self closeFloorPlanFullScreen]; } } - (void)showFloorPlanFullScreen { CGRect newRect = [self.imageView convertRect:self.imageView.bounds toView:[self.splitViewController.view superview]]; UIImage *image = self.imageView.image; self.fullScreenImageView = [[[UIImageView alloc] initWithImage:image] autorelease]; UIPinchGestureRecognizer *pinchGesture = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)] autorelease]; UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)] autorelease]; tapGesture.numberOfTapsRequired = 2; self.fullScreenImageView.userInteractionEnabled = YES; self.fullScreenImageView.multipleTouchEnabled = YES; [self.fullScreenImageView addGestureRecognizer:pinchGesture]; [self.fullScreenImageView addGestureRecognizer:tapGesture]; self.fullScreenImageView.contentMode = UIViewContentModeScaleAspectFit; self.fullScreenImageView.frame = newRect; self.fullScreenImageView.backgroundColor = [UIColor clearColor]; [[self.splitViewController.view superview] addSubview:self.fullScreenImageView]; CGRect splitViewRect = self.splitViewController.view.frame; [UIView animateWithDuration:0.5 animations:^{ self.fullScreenImageView.backgroundColor = [UIColor blackColor]; self.fullScreenImageView.frame = splitViewRect; }]; } - (void)closeFloorPlanFullScreen { CGRect newRect = [self.imageView convertRect:self.imageView.bounds toView:[self.splitViewController.view superview]]; [UIView animateWithDuration:0.5 animations:^{ self.fullScreenImageView.backgroundColor = [UIColor clearColor]; self.fullScreenImageView.frame = newRect; } completion:^(BOOL finished) { [self.fullScreenImageView removeFromSuperview]; self.fullScreenImageView = nil; }]; } </code></pre> <p>If you want the picture to actual resize while zooming, I would recommend adding the duplicate view as soon as the pinching starts (and as long as its scaling > 1) and then apply the transformation:</p> <pre><code>CGAffineTransform myTransformation = CGAffineTransformMakeScale(((UIPinchGestureRecognizer *)sender).scale, ((UIPinchGestureRecognizer *)sender).scale); self.fullScreenImageView.transform = myTransformation; </code></pre> <p>As soon as the pinching hits a end state, I would then fade in the black and adjust the frame. I decided not to go with this method as I think just recognizing the pinch out or double tap is good enough.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload