Skip to content

Instantly share code, notes, and snippets.

@maxkramer
Created February 7, 2011 02:12
Show Gist options
  • Save maxkramer/813923 to your computer and use it in GitHub Desktop.
Save maxkramer/813923 to your computer and use it in GitHub Desktop.
#define IMAGE_WIDTH 320
#define IMAGE_HEIGHT 480
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *photos = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.jpg"],[UIImage imageNamed:@"2.jpg"],[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"4.jpg"], nil]; // TODO – fill with your photos
// note that the view contains a UIScrollView in aScrollView
int i=0;
for ( NSString *image in photos )
{
UIImage *image = [UIImage imageNamed:[photos objectAtIndex:i]];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.clipsToBounds = YES;
imageView.frame = CGRectMake( IMAGE_WIDTH * i++, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
[scrollView addSubview:imageView];
[imageView release];
}
scrollView.contentSize = CGSizeMake(IMAGE_WIDTH*i, IMAGE_HEIGHT);
scrollView.delegate = self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment