Reputation: 919
I have implemented an UIScrollView.It contains small images of 60 width size. The scroll movement always steps 3 pictures forward or back, not one by one as I need. Please see the attached pictures that explain this point.
ScrollView has paging enabled. Here is the code:
for (int i = 0; i < numberOfViews; i++) {
UIImage *myImage = [UIImage imageNamed:[fotosJugadores objectAtIndex:i]];
CGFloat yOrigin = i * myImage.size.width + 120;
UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, myImage.size.width, myImage.size.height)];
awesomeView.image = myImage;
awesomeView.tag = i;
[self.jugadorSlide addSubview:awesomeView];
awesomeView=nil;
}
[jugadorSlide setBackgroundColor:[UIColor blackColor]];
jugadorSlide.contentSize = CGSizeMake(65 * numberOfViews+240,78);
jugadorSlide.layer.cornerRadius = 11;
jugadorSlide.layer.masksToBounds = YES;
[jugadorSlide setContentOffset:CGPointMake(((65 * numberOfViews)/2), 0)];
[self scrollViewDidEndDecelerating:jugadorSlide];
Many thanks
Upvotes: 2
Views: 3491
Reputation: 12949
Ok, I think I know what you mean. Would these links help you
UIScrollView - with paging enabled, can I "change" the page width?
Paging UIScrollView with different page widths
UIScrollView + pagingEnabled, scroll half a page?
Hope this helps
Upvotes: 2