title: How to create grid of UIImageView dynamic using for loop?
body: <p>I want to create a dynamic grid using for loop but I can't. I create demo here but it is not work and I can't understand the logic of this because I'm new in this.</p>
  
  <p>It is important that I have to use for loop no others. So please give me any solutions using for loop. This is in my viewDidLoad method.</p>
  
  <pre><code>int x=5;
  int y=5;
  int hei=50;
  int wid=50;
  
  for (int i=0; i&lt;3; i++) 
  {
      for(int j=0;j&lt;3;j++)
      {
          if (i==0 &amp;&amp; j==0)
          {
              imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, wid, hei)];
              [imageView1 setImage:[UIImage imageNamed:@"Motocross.png"]];
              [self.view addSubview:imageView1];                        
          }
          else 
          {
              imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(x+wid+5, y+hei+5, wid, hei)];
              [imageView1 setImage:[UIImage imageNamed:@"Motocross.png"]];
              [self.view addSubview:imageView1];
          }
  
      }   
  }
  </code></pre>
  
  <p>In that I want to create dynamic grid and the size of UIimageView is 50*50 and the space between UIImageView is 5. So in demo I generates only 3*3 grid (same as gallery in mobile).</p>