Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is your whole <code>UIImageView</code> zoomed, not only its image, but also the gray bars. Your scrollView is just honestly reflecting this. The result you want probably can be done like this:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIImage *image = [UIImage imageNamed:@"IMG_0300.JPG"]; CGFloat ratio = CGRectGetWidth(self.scrollView.bounds) / image.size.width; self.imageView.bounds = CGRectMake(0, 0, CGRectGetWidth(self.scrollView.bounds), image.size.height * ratio); self.imageView.center = CGPointMake(CGRectGetMidX(self.scrollView.bounds), CGRectGetMidY(self.scrollView.bounds)); self.imageView.image = image; self.scrollView.clipsToBounds = YES; self.scrollView.contentSize = self.imageView.bounds.size; self.scrollView.zoomScale = 1.0; self.scrollView.maximumZoomScale = 10.0; self.scrollView.minimumZoomScale = 1.0; } - (void)scrollViewDidZoom:(UIScrollView *)scrollView { UIView *subView = self.imageView; CGFloat offsetX = (scrollView.bounds.size.width &gt; scrollView.contentSize.width)? (scrollView.bounds.size.width - scrollView.contentSize.width) * 0.5 : 0.0; CGFloat offsetY = (scrollView.bounds.size.height &gt; scrollView.contentSize.height)? (scrollView.bounds.size.height - scrollView.contentSize.height) * 0.5 : 0.0; subView.center = CGPointMake(scrollView.contentSize.width * 0.5 + offsetX, scrollView.contentSize.height * 0.5 + offsetY); } -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; } </code></pre>
    singulars
    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.
 

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