2
votes

I have a UIScrollView containing a UIView in Interface Builder. In the running application, even though the view is larger than the scrollView, when I pan the scrollView, it always bounces back to the origin. Until, that is, I zoom the scrollView with a pinch gesture. Afterwards the panning leaves the contained view in a correct state.

Am I missing some setting about pan/zoom in the scrollView, or a contentOffset setting? I cannot figure out what changes about the scroolView from before zooming to after zooming that makes it work as desired after but not before. Anyone who has solved this issue, thank you!

3

3 Answers

5
votes

I had the exact same problem! Found the answer in this post and adapted it to iOS.

Basically, make sure you are setting the delegate and zoomScales in this order:

scrollView.delegate = self;
scrollView.minimumZoomScale = 0.1;
scrollView.maximumZoomScale = 4.0;
scrollView.zoomScale = 1.0;

Then it should work!

1
votes

I had exactly the same problem, and I tried everything to fix it. I was using the interface builder to define a UIScrollView and a UIImageView as a subview for it to scroll an image.

It started to work after I deleted both views from the interface builder and created them programatically.

Remember to add the imageView as a subview for the scrollView:

[scrollView addSubview:imageView];
0
votes

Move contentSize setting to viewDidAppear, and don't ask me why. ;)