Posted By

espinallab on 03/01/10


Tagged

scroll view images a in


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

shimdh
umang_nine
cnathan


Images in a Scroll View


 / Published in: Objective C
 

URL: http://www.chewyapps.com/2009/09/01/images-in-a-scroll-view/

  1. #define IMAGE_WIDTH 320
  2. #define IMAGE_HEIGHT 416
  3.  
  4. - (void)viewDidLoad
  5. {
  6. [super viewDidLoad];
  7.  
  8. NSArray *photos = nil; // TODO – fill with your photos
  9.  
  10. // note that the view contains a UIScrollView in aScrollView
  11.  
  12. int i=0;
  13. for ( NSString *image in photos )
  14. {
  15. UIImage *image = [UIImage imageNamed:[photos objectAtIndex:i]];
  16. UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
  17. imageView.contentMode = UIViewContentModeScaleAspectFit;
  18. imageView.clipsToBounds = YES;
  19.  
  20. imageView.frame = CGRectMake( IMAGE_WIDTH * i++, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
  21.  
  22. [aScrollView addSubview:imageView];
  23. [imageView release];
  24. }
  25. aScrollView.contentSize = CGSizeMake(IMAGE_WIDTH*i, IMAGE_HEIGHT);
  26. aScrollView.delegate = self;
  27. }

Report this snippet  

You need to login to post a comment.