I am placing array of images in a scrollview.
I need to autoscroll the scrollview. I am using the timer and increasing the position of scrollview.
My code looks like this.
- (void)autoscrollmethod {
Timer = [NSTimer scheduledTimerWithTimeInterval:7.5 target:self selector:@selector(moveRect) userInfo:nil repeats:YES];
}
- (void)moveRect {
NSLog(@">>>>>>>> %d",i);
;
if (i==(arraycount+1)*100) {
;
i=200;
}
else {
i=i+100;
}
}
It working fine,but I have a problem.
I am scrolling the view to position 800, but scrollRectToVisible:CGRectMake is at 600,then scrollview is not getting back to 600 position,and not autoscroll up to 800.
After 800 it will automatically scrolls normally.
How can I fix this?
Generally speaking, you should use the
contentOffsetproperty of theUIScrollViewinstead of manually using your own increment variable. Contentoffset changes depending on your scrolling and automatically changes itself.