ios - UIScrollView -setContentOffset : animated YES or NO produce different results -


hei, know sounds stupid. i'm programming first uiscrollview , i'm trying set position of elements inside scroll view according parameter. found can use setcontentoffset no matter values feed function result same , have no idea why? (is problem of contentsize of scroll view?)

here code:

first set scroll view this:

//make view scrollable scrollview=[[uiscrollview alloc]initwithframe:cgrectmake(0, 0, [[uiscreen mainscreen] bounds].size.width, [[uiscreen mainscreen] bounds].size.height-216-30)]; scrollview.scrollstotop = no; scrollview.bounces=no; [self.view addsubview: scrollview]; scrollview.contentsize=cgsizemake([[uiscreen mainscreen] bounds].size.width, [[uiscreen mainscreen] bounds].size.height-110); 

and later try set position of scroll view

 if(ymultiplier==4){                 [scrollview setcontentoffset:cgpointmake(0,imageheight) animated:no];                 nslog(@"4");             } else     if(ymultiplier==5){                 [scrollview setcontentoffset:cgpointmake(0,imageheight*2) animated:no];                 nslog(@"4");             } 

edit: no matter y coordinate of cgpoint scrolls exact same point. have tried use animated: yes. results in different. scrolls intended position have new problem: adding several images based on user types, scroll works fine every other image. , second image scrolls original position... code that

if(ymultiplier>3){             cgpoint bottomoffset = cgpointmake(0, imageheight*3);             [scrollview setcontentoffset:bottomoffset animated:yes];         } 

edit: logging offset in - (void)scrollviewdidscroll:(uiscrollview *)scrollview{ nslog(@"offset: %f, %f",scrollview.contentoffset.x, scrollview.contentoffset.y); } gives this:

intially:

offset: 0.000000, -64.000000 offset: 0.000000, -64.000000 

when going right position:

2014-06-26 16:56:28.722 ualphabets[5058:60b] offset: 0.000000, -63.500000 2014-06-26 16:56:28.739 ualphabets[5058:60b] offset: 0.000000, -61.500000 2014-06-26 16:56:28.756 ualphabets[5058:60b] offset: 0.000000, -57.500000 2014-06-26 16:56:28.772 ualphabets[5058:60b] offset: 0.000000, -51.500000 2014-06-26 16:56:28.789 ualphabets[5058:60b] offset: 0.000000, -44.000000 2014-06-26 16:56:28.806 ualphabets[5058:60b] offset: 0.000000, -35.000000 2014-06-26 16:56:28.822 ualphabets[5058:60b] offset: 0.000000, -25.500000 2014-06-26 16:56:28.839 ualphabets[5058:60b] offset: 0.000000, -14.500000 2014-06-26 16:56:28.855 ualphabets[5058:60b] offset: 0.000000, -3.500000 2014-06-26 16:56:28.872 ualphabets[5058:60b] offset: 0.000000, 7.500000 2014-06-26 16:56:28.889 ualphabets[5058:60b] offset: 0.000000, 18.500000 2014-06-26 16:56:28.905 ualphabets[5058:60b] offset: 0.000000, 29.000000 2014-06-26 16:56:28.922 ualphabets[5058:60b] offset: 0.000000, 39.000000 2014-06-26 16:56:28.939 ualphabets[5058:60b] offset: 0.000000, 47.000000 2014-06-26 16:56:28.956 ualphabets[5058:60b] offset: 0.000000, 54.000000 2014-06-26 16:56:28.972 ualphabets[5058:60b] offset: 0.000000, 59.500000 2014-06-26 16:56:28.989 ualphabets[5058:60b] offset: 0.000000, 63.500000 2014-06-26 16:56:29.005 ualphabets[5058:60b] offset: 0.000000, 65.000000 

with every other images jumping wrong place:

2014-06-26 16:56:31.516 ualphabets[5058:60b] offset: 0.000000, 12.500000 


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -