Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top