Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.85 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to show multiple image getting from xml
  2. CGRect baseFrame = CGRectMake(kXOffset, xYOffset, kImageSize, kImageSize);
  3.     int count = [myArray count]; // myArray contains your data
  4.     for (int i = 0; i < count; i++) {
  5.         NSDictionary *unit = [myArray objectAtIndex:i];
  6.         CGRect buttonFrame = baseFrame;
  7.         buttonFrame.origin.y += (kImageSize + kSpacing) * (i / 3);
  8.  
  9.         // "imageName" below is a sample key for your image name, you can change this with url or whatever
  10.         UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[unit objectForKey:@"imageName"]]];
  11.         [img setFrame:buttonFrame];
  12.         [myScrollView addSubview:img];
  13.         [img release]; // if not using ARC
  14.     }
  15.     [myScrollView setContentSize:CGSizeMake(320, 20 + (kImageSize + 2 * kSpacing) * ([army count] / 3))]; // some air above and below