Created
October 27, 2013 19:24
-
-
Save Qiki/7186792 to your computer and use it in GitHub Desktop.
Showing various images in a scroll view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.scrollView.pagingEnabled = YES; // making the image can scroll one by one | |
+ for(NSInteger i = 0; i < self.imageURL.count;i++){ //doing several loop to add the image on the scroll view | |
+ | |
+ CGFloat xOrigin = i * self.view.frame.size.width; | |
+ UIImageView *awesomeView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height-90)]; | |
+ [awesomeView setImageWithURL:self.imageURL[i][@"2x"]]; | |
+ [self.scrollView addSubview:awesomeView]; | |
+ } | |
+ | |
+ [self.scrollView setContentOffset:CGPointMake([self.tag integerValue] * self.view.frame.size.width, 0) animated:NO];//set offset-- which means the first image show- basing on the width and do calculation | |
+ self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width * self.imageURL.count, 1); //the overall scrollview size | |
+ [self.view addSubview:self.scrollView];//add the scroll view into the view. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment