J.Doe J.Doe - 2 months ago 5
Swift Question

Acheiving a scroll-view look for large amounts of "views"?

The effect I'm wanting to accomplish is somewhat similar to Tinder where you're presented a "View" or a screen about people 1 "screen" at a time, and you're able to swipe left and right to be able to see the other pictures, but while you're scrolling you're not totally refreshing the page, you can see the old "page" go off the screen while the new one is coming in.

I'm not sure where to even start with this. I could get that effect with a scrollview and use the built in snapping effect to make it exactly how I'd want. What I've read/heard from quite a few sources is that you want to avoid using scrollviews if you're going to have a lot of pictures loading into it, and there's the potential here for me to have 300 pitures coming in from firebase that I'd want to scroll through.

If I'm correct about scrollviews, that would also run into the issue of having to load up and place every single picture and not allow for a table-view dequeue situation. They'd all literally be loaded in and placed and it'd be awful especailly if the person only wants to look at the first one or two pictures.

How is this kind of look achieved? Basically if I have 3 views with a picture/ some buttons/ some labels named A B and C.. I want my initial view to be A then if I swipe right the screen "scrolls" over to B" just like it works in a scrollview and snaps to B once it's reached the checkpoint, then left or right to either get to C or A again...while also allowing to keep track of a indexPath.row on the buttons maybe using tags?

Any ideas would be greatly appreciated. I think I'm overlooking some built-in functionality that would make this pretty easy but I'm not seeing what tools would allow for this.


Sounds like you want UIPageViewController:

A page view controller lets the user navigate between pages of content, where each page is managed by its own view controller object. Navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change.

There are many tutorials available on the Internet. Consult your favorite search engine.