Note that there are some explanatory texts on larger screens.

plurals
  1. POZooming UIImageView and moving inside the zoom
    text
    copied!<p>in my UIScrollview i have a UIImageView with a black background. Inside of it there is another UIImageView with a UIImage inside and i use this code to enable the zoom:</p> <pre><code>fullImageView = [[UIView alloc] initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)]; fullImageView.backgroundColor = [UIColor blackColor]; [fullImageView addSubview:copyImageToShowImageView]; zoomFullImageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)]; [zoomFullImageScrollView addSubview:fullImageView]; [self.view addSubview:zoomFullImageScrollView]; UIPinchGestureRecognizer *twoFingerTapRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapImage:)]; [copyImageToShowImageView addGestureRecognizer:twoFingerTapRecognizer]; //Then.. - (void)doubleTapImage:(UIPinchGestureRecognizer *)gesture{ if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateChanged) { CGFloat currentScale = copyImageToShowImageView.frame.size.width / copyImageToShowImageView.bounds.size.width; CGFloat newScale = currentScale * gesture.scale; NSLog(@"gesture.scale = %f", currentScale * gesture.scale); if (newScale &lt; 1) { newScale = 1; } if (newScale &gt; 100) { newScale = 100; } CGAffineTransform transform = CGAffineTransformMakeScale(newScale, newScale); copyImageToShowImageView.transform = transform; gesture.scale = 1; copyImageToShowImageView.transform = CGAffineTransformTranslate(copyImageToShowImageView.transform, newScale, newScale); zoomFullImageScrollView.contentSize=CGSizeMake(copyImageToShowImageView.frame.size.width, copyImageToShowImageView.frame.size.height); } } //and the methods: - (void)viewDidLoad { NSLog(@"super"); [super viewDidLoad]; zoomFullImageScrollView.minimumZoomScale=0.5; zoomFullImageScrollView.maximumZoomScale=6.0; zoomFullImageScrollView.delegate=self; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ return copyImageToShowImageView; } </code></pre> <p>This code works, but there is a problem because the scrollview content size is different from the UIImageView size. Maybe they're equal but not aligned. Then i'd like that when the user makes the zoom, the image zooms there, not always from the center, but this is not important..</p> <p>I hope i explained myself.</p> <p>How can i do?</p>
 

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