title: Create multiple UIImageViews programmatically
body: <p>I want to create multiple UIImageViews programmatically with different tags and add them as subview of my main view.</p>
  
  <p>I have a property of my UIImageView in header:</p>
  
  <pre><code>@property (strong, nonatomic) UIImageView *grassImage;
  </code></pre>
  
  <p>then i'm trying to create multiple views:</p>
  
  <pre><code>for (int i=0;i&lt;13;i++){
  
          grassImage = [[UIImageView alloc] init];
  
          int randNum = arc4random() % 320; //create random number for x position.
  
          [grassImage setFrame:CGRectMake(randNum, 200.0, 50.0, 25.0)];
          [grassImage setTag:i+100];
          [grassImage setImage:[UIImage imageNamed:@"grass"]];
  
          [self.view addSubview:grassImage];
      }
  </code></pre>
  
  <p>But when I'm trying to access this image views using tag, I'm getting only last tag - 112.</p>
  
  <p>My question - how I can access this views correctly, using their tag?</p>
  
  <p>Similar questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2646297/add-a-multiple-buttons-to-a-view-programatically-call-the-same-method-determin">Add a multiple buttons to a view programmatically, call the same method, determine which button it was</a></li>
  </ul>