title: Adding an array of buttons to a particular subview
body: <p>I have a subview that is hidden until a user clicks a button (The subview is a UIScrollview).  I'd like to programmatically add a grid of buttons in that view.  I'm not sure how to specify which view the buttons get added to.  I'm trying to follow <a href="http://www.raywenderlich.com/130/how-to-write-a-custom-image-picker-like-uiimagepicker" rel="nofollow">http://www.raywenderlich.com/130/how-to-write-a-custom-image-picker-like-uiimagepicker</a></p>
  
  <p>the scrollview is called graphicView</p>
  
  <p>This is what I have</p>
  
  <pre><code> for(int i=0;i&lt;64;i++)
  {
  UIImage *buttonImage=[UIImage imageNamed:@"image.png"];
  
      [arrayOfThumbnails addObject:buttonImage];  
  }
  
  
  
  for(int i = 0; i &lt; arrayOfThumbnails.count; ++i) {
  
      UIImage *thumb = [arrayOfThumbnails objectAtIndex:i];
      UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
      button.frame = CGRectMake(column*100+24, row*80+10, 64, 64);
      [button setImage:thumb forState:UIControlStateNormal];
      [button addTarget:graphicView
                 action:@selector(buttonClicked:)
       forControlEvents:UIControlEventTouchUpInside];
      button.tag = i;
      [graphicView addSubview:button];
  
      if (column == 2) {
          column = 0;
          row++;
      } else {
          column++;
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p>This is the only part I'm not using from the tutorial....</p>
  
  <blockquote>
    <p>[view setContentSize:CGSizeMake(320, (row+1) * 80 + 10)];     self.view
    = view;</p>
  </blockquote>
  
  <hr>