UIScrollView always snaps back

2019-06-26 03:47发布

问题:

I put a bunch of objects into a UIScrollView and I no have a problem: When I try to "scroll" to some off-screen objects, they appear so long as I am holding my finger down after dragging it, but when I let you, the UIScrollView snaps back to the original position.

Is there a way to prevent this? No off-screen gray area is appaering when this happens, BTW.

Thanks.

回答1:

You have to set the scroll view's contentSize to include your objects, so it knows how large the scrollable area is — how far to scroll freely before it hits the edge and bounces back.