Reputation: 33
I have one scrollview that contain about 11 images and the scrollView will show only one image on screen. I need to make it autoscroll image by image. I did something like this:
[UIView animateWithDuration:120
delay:1
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
animations:^{
self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x+172*11,0);
}
completion:nil];
the scrollview scroll through all the width its has and i can see the connection between the image. Is it possible to autoscroll by setting the contentOffset?
Thanks
Upvotes: 1
Views: 690
Reputation: 1249
I made my UIScrollView Auto Scroll by set contentOffset like this:
[NSTimer scheduledTimerWithTimeInterval:.0 target:self selector:@selector(loadUrl) userInfo:nil repeats:NO];
- (void) loadUrl
{
currentOffset = scrlFirstScroll.contentOffset.y;
CGFloat newOffset = currentOffset + 3;
[scrlFirstScroll setContentOffset:CGPointMake(0.0,newOffset) animated:YES];
}
Hope this will help..
Upvotes: 5