Horizontal UIScrollView and hundreds of thumbnail images in iOS? Horizontal UIScrollView and hundreds of thumbnail images in iOS? ios ios

Horizontal UIScrollView and hundreds of thumbnail images in iOS?


You can add all the thumbnails programatically to your scrollview and use the setContentSize method of UIScrollView. you have to pass 2 values in contentOffset. 1 for width and 1 for height. Please follow link to explore more on this. If you need further help please leave a comment.

Hope it helps.

Please consider Following example.

- (void)setupHorizontalScrollView{scrollView.delegate = self;[self.scrollView setBackgroundColor:[UIColor blackColor]];[scrollView setCanCancelContentTouches:NO];scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;scrollView.clipsToBounds = NO;scrollView.scrollEnabled = YES;scrollView.pagingEnabled = YES;NSUInteger nimages = 0;NSInteger tot=0;CGFloat cx = 0;for (; ; nimages++) {    NSString *imageName = [NSString stringWithFormat:@"image%d.jpg", (nimages + 1)];    UIImage *image = [UIImage imageNamed:imageName];    if (tot==15) {        break;    }    if (4==nimages) {        nimages=0;    }    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];    CGRect rect = imageView.frame;    rect.size.height = 40;    rect.size.width = 40;    rect.origin.x = cx;    rect.origin.y = 0;    imageView.frame = rect;    [scrollView addSubview:imageView];    [imageView release];    cx += imageView.frame.size.width+5;    tot++;}self.pageControl.numberOfPages = nimages;[scrollView setContentSize:CGSizeMake(cx, [scrollView bounds].size.height)];}


Check out bjhomer's HSImageSidebarView project. It lets you load a scrollview horizontally or vertically and load in the images. Super easy to implement.