views:

659

answers:

1

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!

+2  A: 

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
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