How to implement zooming *and* paging like iOS Pho

2019-04-14 12:07发布

问题:

In Apple's photo's app you can swipe between photos while viewing, and also zoom into and pan around a photo. When you get to the edge of a zoomed photo you can still swipe into the next image - what kind of scrollview setup is needed to allow this?

回答1:

There's an excellent video from WWDC 2010 - https://developer.apple.com/videos/wwdc/2010/

The session is titled "Designing Apps with Scroll Views". It's a step-by-step of exactly what you're asking.

Per omz's response, the paging scroller part is pretty straight forward. But Apple does some more complex things with how the zoomable scroll views are created and reused. You really should check out the video.



回答2:

The easiest way to do this is to create one scroll view that scrolls only horizontally and has pagingEnabled set to YES. Each page of this scroll view then contains another zoomable scroll view for an individual photo.