6

What am I doing wrong? Here is how I create + populate my scrollView

    -(void)viewDidAppear:(BOOL)animated {

    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bigimage.jpg"]];
    imgView.contentMode = UIViewContentModeScaleAspectFit;

    scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    scrollView.contentSize = imgView.frame.size;

    scrollView.minimumZoomScale =  scrollView.frame.size.width / scrollView.contentSize.width * 0.99;
    scrollView.maximumZoomScale =  2;

    [self.view addSubview:scrollView];


[scrollView addSubview:imgView];

    [scrollView setZoomScale:0.5 animated:YES];
    NSLog(@"current zoomScale: %f", scrollView.zoomScale);
    [imgView release];
}

The NSLogged zoomScale is 1.0, and the image is clearly shown at full size. Pinch zoom does not do anything. I've tried almost everything I can find on the net, but everybody seems to be doing exactly this, and it works for them.

Help is vastly appreciated!

Kenny Winker
  • 11,919
  • 7
  • 56
  • 78

1 Answers1

21

A UIScrollView will not zoom unless it has its delegate property set to a valid UIScrollViewDelegate that responds to

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;

Check out  the documentation.

Ed Marty
  • 39,590
  • 19
  • 103
  • 156
  • THANK YOU! I just found this somewhere else two seconds ago and had come back to fix my question. Clearly I'm not reading the docs hard enough. – Kenny Winker Nov 30 '09 at 05:08