I have made scrollview for the few collection of images and I want it to autoscroll the images one by one by the interval of 2 sec. By the below code I could able to make all images slide at a time, but I want one image to scroll then other with respect to time.
-(void)scrollPages{
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.contentSize = CGSizeMake(320, 465);
[scrollView setScrollEnabled:YES];
[scrollView setPagingEnabled:YES];
[scrollView setAlwaysBounceVertical:NO];
[self.uiSubView addSubview:scrollView];
NSMutableArray *arrImage = [NSMutableArray arrayWithObjects:@"a.jpeg", @"cat.jpg", @"s.jpeg",@"ss.jpeg", nil];
for (int i = 0; i < [arrImage count]; i++)
{
CGFloat xOrigin = i * scrollView.frame.size.width;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
[imageView setImage:[UIImage imageNamed:[arrImage objectAtIndex:i]]];
[imageView setContentMode: UIViewContentModeScaleAspectFit];
[scrollView addSubview:imageView];
}
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width * [arrImage count], scrollView.frame.size.height)];
CGFloat currentOffset = scrollView.contentOffset.x;
if(currentOffset < 2500){
CGFloat newOffset = currentOffset + 1250;
[UIScrollView beginAnimations:nil context:NULL];
[UIScrollView setAnimationDuration:3];
[scrollView setContentOffset:CGPointMake(newOffset,0.0) animated:YES];
}