title: Create frame and put button inside of frame in Objective-C
body: <p>I want to create view with 52 square or button (for 52 week in a year in one page) with grid but I don't know how should I align them or how should I put them in a frame </p>
  
  <p>(you will have 13 rows and 4 columns), but if you try this code it's not algin :
  I don't know how should I create frame to put all of buttons in side of my frame..</p>
  
  <p>Here is my code:</p>
  
  <pre><code>- (void)viewDidLoad
  {
  [super viewDidLoad];
  int rows = 13, columns = 4;
  
  for (int y = 0; y &lt; rows; y++) {
      for (int x = 0; x &lt; columns; x++) {
          UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
          button.frame = CGRectMake(58 * x, 31 * y, 58, 31);
  
          [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
          [self.view addSubview: button];
  
      }
  }
  
  
  
  }
  
  
   -(void)buttonPressed:(UIButton *)button
  {
  NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
  }
  </code></pre>