
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 0.85 KB | hits: 13 | expires: Never
how to show multiple image getting from xml
CGRect baseFrame = CGRectMake(kXOffset, xYOffset, kImageSize, kImageSize);
int count = [myArray count]; // myArray contains your data
for (int i = 0; i < count; i++) {
NSDictionary *unit = [myArray objectAtIndex:i];
CGRect buttonFrame = baseFrame;
buttonFrame.origin.y += (kImageSize + kSpacing) * (i / 3);
// "imageName" below is a sample key for your image name, you can change this with url or whatever
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[unit objectForKey:@"imageName"]]];
[img setFrame:buttonFrame];
[myScrollView addSubview:img];
[img release]; // if not using ARC
}
[myScrollView setContentSize:CGSizeMake(320, 20 + (kImageSize + 2 * kSpacing) * ([army count] / 3))]; // some air above and below