Posted By

mracoker on 02/26/10


Tagged

image grid


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

umang_nine
bucko
Tintenklecks
cnathan


Image Grid


 / Published in: Objective C
 

  1. -(void)FillView
  2. {
  3. @try
  4. {
  5. int cnt = 0;
  6. int x=0,y=0;
  7. NSInteger pNumber=1;
  8.  
  9. for( i = 0; i < 100; i++)
  10. {
  11. for(int colIndex = 0; colIndex < 3; colIndex++)
  12. {
  13. if(pNumber > 3)
  14. {
  15. pNumber = 1;
  16. }
  17.  
  18. cnt = cnt + 1;
  19. NSString *pictureName = [[NSString alloc] initWithFormat:@"http://www.xyz.com/ball00%d.png", cnt];
  20.  
  21. UIImage *img= [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithStringictureName]]];
  22. if(img == NULL)
  23. {
  24. [btnSelect setUserInteractionEnabled:YES];
  25. [self.view setClipsToBounds:YES];
  26.  
  27. return;
  28. }
  29.  
  30. UIImage *aImage = [UIImage imageNamedictureName];
  31.  
  32. CGRect frame = btnSelect.frame;
  33. frame.origin.x = ((frame.size.width+8) * (colIndex));
  34. frame.origin.y = ((frame.size.height+10) * (i));
  35. btnSelect.frame = frame;
  36. [btnSelect addTarget:self action:@selector(ClickButton forControlEvents:UIControlEventTouchUpInside];
  37. [self.view addSubview:btnSelect];
  38.  
  39. x = frame.origin.x;
  40. y = frame.origin.y;
  41.  
  42. pNumber = pNumber + 1;
  43. u = u + 1;
  44. [pictureName release];
  45. [aImage release];
  46. }
  47. }
  48.  
  49. }
  50. @catch (NSException * e)
  51. {
  52. //continue;
  53. //NSLog(@"%@",e);
  54. }
  55. }

Report this snippet  

You need to login to post a comment.