iphone - Progressively scrolling child scrollView -


i have 2 scrollviews, smaller scrollview needs scroll little bit slower (and stop on next "page) larger scrollview. basically, scrolling larger scrollview scrolls smaller scrollview, @ slower pace larger scrollview. (confusing know).

so scrollview1 (the larger) , scrollview2, smaller: swipe scrollview1, scrollview2 scrolling slower. both having paging enabled , contentsizes have been set based on scrollview2's content.

i having trouble calculating offset between 2 scroll perfectly.

enter image description here

- (void)scrollviewdidscroll:(uiscrollview *)scrollview {     if ( scrollview == scrollview1 )     {         cgfloat xoffset = (scrollview2.contentsize.width * scrollview1.contentsize.width); // issue          [scrollview2 scrollrecttovisible:cgrectmake(xoffset, 0, scrollview2.frame.size.width, scrollview2.frame.size.height) animated:yes];     } } 

try replacing 2 lines with:

float xoffset = scrollview1.contentoffset.x * (scrollview2.frame.size.width / scrollview1.frame.size.width); [scrollview2 setcontentoffset:cgpointmake(xoffset,0) animated:yes]; 

this take offset of scrollview1, divide difference in frame sizes between 2 views, , set scrollview2's contentoffset value (which better scrolling rect visible).


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -