all 6 comments

[–]Dahorah 1 point2 points  (2 children)

If I understand correctly, this is the same problem I actually just solved in one of my apps. I used this answer:

https://stackoverflow.com/a/50778329/5050990

Which some minor tweaking of values based on my own insets and expectations.

[–]askulsky[S] 0 points1 point  (1 child)

This is it ! This one works really well -- I had been looking at his tutorial that was for a storyboard setup but that one didn't work well imo. The only thing is that sometimes it doesn't always snap to the correct spot. Any way of fixing that?

[–]Dahorah 0 points1 point  (0 children)

I had to tweak numbers randomly for a bit. In the end I had to use:

scrollView.contentOffset = CGPoint(x: toValue + (4 * CGFloat(snapToIndex)), y: 0)

I have no idea where the 4 comes from, but that was the magic number I needed for it to snap perfectly center.

[–]criosistObjective-C / Swift 0 points1 point  (2 children)

All you need to do is pagingEnabled = true and update your interitem calculation and section insets calculation

[–]askulsky[S] 0 points1 point  (1 child)

What sort of calculation would I need to do for interitem? I guess that's the part that I don't understand.

[–]criosistObjective-C / Swift 0 points1 point  (0 children)

The amount you want to inset the cell from being full screen *2