Set UIImageView Size?

Posted by Tronic on Stack Overflow See other posts from Stack Overflow or by Tronic
Published on 2010-04-22T19:55:29Z Indexed on 2010/04/22 20:03 UTC
Read the original article Hit count: 1248

Filed under:
|
|
|
|

hi,

i have following problem: i generate subviews UIView in an UIScrollView including UIImageViews.

NSArray *bilder = [[NSArray alloc] initWithObjects:@"lol.jpg", @"lol2.jpg", nil];
NSArray *added = [[NSMutableArray alloc] init];
UIImageView *tmpView;

for (NSString *name in bilder) {
    UIImage *image = [UIImage imageNamed:name];
    tmpView = [[UIImageView alloc] initWithImage:image];
    tmpView.contentMode = UIViewContentModeScaleAspectFit;
    tmpView.frame = CGRectMake(0, 0, 300, 300);

    [added addObject:tmpView];

    [tmpView release];
}

CGSize framy = mainFrame.frame.size;

NSUInteger x = 0;

for (UIView *view in added) {
    [mainFrame addSubview:view];
    view.frame = CGRectMake(framy.height * x++, 0, framy.height, framy.width);
}

mainFrame.scrollEnabled = YES;
mainFrame.pagingEnabled = YES;
mainFrame.contentSize = CGSizeMake(framy.height * [added count], framy.width);
mainFrame.backgroundColor = [UIColor blackColor];

i get image file names out of an array. now i want to resize the imageview to a specific size, but it won't work. any advice?

thanks + regards

© Stack Overflow or respective owner

Related posts about uiimageview

Related posts about size