uiscrollviewdelegate - How to "stick" a UIScrollView subview to top/bottom when scrolling? -


you see in iphone apps gilt. user scrolls view, , subview apparently "sticks" 1 edges rest of scrollview slides underneath. is, there text box (or whatever) in scrollview, scrollview hits top of view, "sticks" there rest of view continues slide.

so, there several issues. first, 1 can determine via "scrollviewdidscroll:" (during normal scrolling) when view of interest passing (or re-appearing). there fair amount of granularity here - differences between delegate calls can hundred of points or more. said, when see view approach top of scrollview, turn on second copy of view statically displayed under scrollview top. have not coded this, seems lack real "stick" - view first disappear reappear.

second, if 1 setcontentoffset:animated, 1 not delegate messages (gilt not this). so, how callbacks in case? use kvo on "scroll.layer.presentationlayer.bounds" ?

well, found 1 way this. when user scrolls flicking , dragging, uiscrollview gives delegate "scrollviewdidscroll:" message. can see if scroller has moved content need take action.

when "sticking" view, remove scrollview, , add scrollview's superview (with origin of 0,0). when unsticking, converse.

if use uiscrollview setcontentoffset:animated:, gets trickier. did subclass uiscrollview, use flag specify setcontentoffset moving offset, start fast running timer monitor contentoffset.

i put method handles math , sticking/unsticking child view subclass. looks pretty good.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -