ios - UIScrollView automatically scrolls to next subview horizontally then bounces somewhere else -
uiscrollview has several uilabel subviews, set scroll horizontally (think instagram filters scrolling view). can scroll uiscrollsubview, act upon tapping on uilabel subview. next thing achieve programmatically scroll invisible uilabel subview, when users selects last visible subview on right (similar how instagram filters scroll out of visible area when user selects last visible filter).
when user touches last visible uilabel subview, execute
[_scrollview setcontentoffset:cgpointmake(64, 0) animated:yes];
where 64 width of every uilabel subview of scrollview.
this works fine on first selection event of last visible subview. once scrollview scrolled reveal desired subview on right side of selected one, , select newly revealed subview, scrollview correctly scrolls left revealing next invisible subview, jumps (to right) 2 positions (128). desired behaviour scroll left when last visible subview on right selected (right happens on first selection).
any suggestions appreciated.
thanks.
edit: bouncing issue went away in 2 cases:
scrollview.pagingenabled: no;
user performs relatively long touches on subviews
you should add 64 current contentoffset.
[_scrollview setcontentoffset:cgpointmake(_scrollview.contentoffset.x + 64, 0) animated:yes];
Comments
Post a Comment