title: UITableView like gridview in Xcode?
body: <p>Im implementing the concept of UITableView acting like gridView .I am loading NSMutableArrays data in UITableView.I am loading the array items in UIButtons of a tableViewCell and when a button is pressed then some action should be performed..i.e 4 buttons in each row and no of rows depend upon the no of array items.I could do it partially.I can click the button and next action for button goes as long as there are 8 or less than 8 items in the array.But when there are more than that then I can view the buttons getting added but I could not click on buttons(i.e -(IBAction)buttonPressed:(id)sender{ )not responding..Couldnot understand where  I am going wrong..?</p>
  
  <pre><code>sections=[[NSMutableArray alloc] init];
          for(int s=0;s&lt;1;s++)
          {
              NSMutableArray *section=[[NSMutableArray alloc] init];
              for(int i=0;i&lt;[arr1 count];i++)
              {
                  Item *item=[[Item alloc] init];
                  NSString *eventName=[[arr1 objectAtIndex:i]objectForKey:@"Time"];
  
                  item.Time=eventName;
                  [section addObject:item];
  
              }
              [sections addObject:section];
  
          }
          tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,430,320,200) style:UITableViewStylePlain];
          tableView.delegate = self;
          tableView.dataSource = self;
          [self.view addSubview:tableView];   
  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return 1;
  }
  
  -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSMutableArray *sectionItems=[sections objectAtIndex:indexPath.section];
      int numRows=[sectionItems count]/[arr1 count];
      return numRows * 80.0;
  }
  
  -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *hlCellID=@"hlCellID";
  
      UITableViewCell* hlcell=[tableView dequeueReusableCellWithIdentifier:hlCellID];
  
      if(hlcell == nil)
      {
          hlcell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault    reuseIdentifier:hlCellID]autorelease];
  
          hlcell.accessoryType = UITableViewCellAccessoryNone;
          hlcell.selectionStyle = UITableViewCellSelectionStyleNone;    
      }
      int section=indexPath.section;
      NSMutableArray *sectionItems=[sections objectAtIndex:section];
      int n=[sectionItems count];
      int i=0,i1=0;
      while(i&lt;n)
      {
          int yy= 4+i1*34;
          int j=0;
          for(j=0;j&lt;4;j++)
          {
              if(i&gt;=n)break;
             Item *item=[sectionItems objectAtIndex:i];
              CGRect rect=CGRectMake(0+70*j,yy,79,40);
              UIButton *button=[[UIButton alloc] initWithFrame:rect];
              [button setFrame:rect];
              [button setContentMode:UIViewContentModeLeft];
              button.titleLabel.font = [UIFont systemFontOfSize:14];
              NSString *settitle=[NSString stringWithFormat:@"%@",item.Time];
              [button setTitle:settitle forState:UIControlStateNormal];
              NSString *tagValue=[NSString stringWithFormat:@"%d%d",indexPath.section+1,i];
              button.tag=[tagValue intValue];
              [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
              [button setShowsTouchWhenHighlighted:YES];     
              [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
             [hlcell.contentView addSubview:button];
              [button release];
              i++;
  
  
  
  
          }
          i1=i1+1;
      }
      return hlcell;
  
  }
  
  
  
  -(IBAction)buttonPressed:(id)sender
  {
  
      int tagID=[sender tag];
      int divnum=0;
      if(tagID&lt;100)
          divnum=10;
      else
          divnum=100;
      int section=[sender tag]/divnum;
      section-=1;
      int itemId=[sender tag]%divnum;
  
  
      NSMutableArray *sectionItems=[sections objectAtIndex:section];
      Item *item=[sectionItems objectAtIndex:itemId];
  
  }
   In Item class I have NSString *Time;
  </code></pre>
  
  <p>my array is like this :</p>
  
  <pre><code>(
          {
          Time = "9:00 am";
      },
          {
          Time = "9:15 am";
      },
          {
          Time = "9:30 am";
      },
          {
          Time = "9:45 am";
      },
          {
          TimeStart = "10:00 am";
      },
          {
          Time = "10:15 am";
      },
  ......24 objects in the array
  </code></pre>
  
  <p>![How can I get all buttons to be clicked and respond to -(IBAction)][1]</p>