Return to Snippet

Revision: 24423
at March 1, 2010 15:35 by espinallab


Initial Code
#define IMAGE_WIDTH   320
#define IMAGE_HEIGHT  416
       
- (void)viewDidLoad
{
    [super viewDidLoad];
       
    NSArray *photos = 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);
               
                [aScrollView addSubview:imageView];
                [imageView release];
        }
        aScrollView.contentSize = CGSizeMake(IMAGE_WIDTH*i, IMAGE_HEIGHT);
        aScrollView.delegate = self;
}

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

Initial Description

                                

Initial Title
Images in a Scroll View

Initial Tags
images

Initial Language
Objective C