iphone – UIScrollView Vertical Pan Snapping to top or bottom of view – Education Career Blog

I have an image that is 320×480 and upon orientation change this image obviously hangs out of view. There are some images where the focal point of it sits with it’s bottom cut off (which isn’t undesirable). My issue however is when the user pans vertically to see the full image, the view appears to snap to the bottom meaning the top of the focal point is cutoff. What I wish to happen is that the users can “free-scroll” through the image and perhaps move the images so the focal point is centre screen, instead of cutting off the top and bottom. I understand this is a difficult concept to describe in words so I’ve attached some images below.

This is how it starts:

alt text

This is where it snaps to the bottom:

alt text

This is the kind of view I wish to have but cannot:

alt text

Is there a way to control this “snapping” or perhaps a method I could use to override it when dealing specifically with this kind of orientation? My issue is that i WANT it to snap when panning left/right onto the other images in the ScrollView, just not up/down.


pagingEnabled is the property that controls this snapping, but is there anyway to detect if the movement is Up/Down or Left/Right and disable or enable this property in each occasion?

Cheers for any help you can offer


You can try using two nested scroll views; one is limited to scrolling horizontally with paging enabled, and one (or one for each page if you’re displaying several images?) limited to scrolling vertically with paging disabled. By default this will work like you said, paging/snapping horizontally but free scroll vertically. However, it will only let you scroll in one direction at a time (either horizontally or vertically, not diagonally).

If you want to use nested scroll views like this but you’d like to allow scrolling/dragging in both directions simultaneously, take a look at my solution for this: Nested UIScrollViews scrolling simultaneously

Leave a Comment