Manage the scrolling of just one element in a ScrollView

Posted by morgan1189 on Stack Overflow See other posts from Stack Overflow or by morgan1189
Published on 2012-08-27T21:09:40Z Indexed on 2012/08/27 21:38 UTC
Read the original article Hit count: 90

Filed under:
|
|

So, I have a ScrollView which has cards on it. ScrollView must be paging enabled.

The goal is that the user must be able to scroll it, even if it has only one card. Since i am having the frame of ScrollView of exactly the same width and height as a picture of a card, i decided to increase the width of a ScrollView.contentSize and add one point to it.

It turns out to be working fine, but it glitches a bit - when i drag the card to the left, and then grab it again it moves to right a little bit (i guess, for the value of that one point). If i increase the contentSize, the shift increases too (for example, if the content size is increased by ten, the shift value is ten points too). It really irritates me a lot and I want to get rid of it.

Any advice on how to do that? Help is much appreciated.

UPD: I tried to manually re-center the card in the scrollViewDidEndDecelerating but that didn't help. My guess for now is that the problem can be solved by setting the content offset to the right value (because now it's (0,0)), but I can't figure out how to do it.

© Stack Overflow or respective owner

Related posts about ios

Related posts about uiscrollview