Doug Smith
Doug Smith

Reputation: 29326

Why am I unable to zoom my UIImageView embedded in a UIScrollView?

I literally have the most basic of code and I'm so frazzled as to why it won't zoom:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds))];
    self.scrollView.delegate = self;
    self.scrollView.contentSize = self.imageView.bounds.size;
    self.scrollView.minimumZoomScale = 0.5;
    self.scrollView.maximumZoomScale = 10.0;

    [self.view addSubview:self.scrollView];

    self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"community1.jpeg"]];
    self.imageView.contentMode = UIViewContentModeScaleAspectFit;

    [self.scrollView addSubview:self.imageView];
}

In the simulator I try to zoom and nothing at all happens. It's a rather large image if that's relevant.

Upvotes: 1

Views: 89

Answers (1)

jemmons
jemmons

Reputation: 18657

Did you implement -viewForZoomingInScrollView: in your scroll view's delegate? If not, you need to do that, returning the view you want to actually zoom when you pinch.

Upvotes: 1

Related Questions