title: How to make a-two-column UITableViewController list?
body: <p>I need to present my table view with a two column list. I read some related posts about making some grid by overriding drawRect (<a href="https://stackoverflow.com/questions/506601/iphone-multiple-columns-in-uitableview">here</a>). However, I'm seeking a simple way to design my cell with IB in nib, then load it and push two cells on each row. The example with drawRect is not appropriate because it involves manual setting of positions. I just need to push those two cells with some autosizing, that's it. Is it possible? </p>
  
  <p>I'm looking for something like (in cellForRowAtIndexPath):</p>
  
  <pre><code>cell.contentView = emptyUIViewContainer;
  [cell.contentView addSubview:FirstColumnUIView];
  [cell.contentView addSubview:SecondColumnUIView];
  </code></pre>
  
  <p>I don't need to have two separate nibs for those two columns because every column is of the same format just with some other data. Any ideas?</p>
  
  <p>UPDATE: Intuitively, I'm trying to do something like this:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell1 == nil) {
      cell1 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    // Configure the first cell.
    cell1.textLabel.text = ...some text
  
    // Configure the second cell
    UITableViewCell *cell2 = [[UITableViewCell alloc] init];
    cell2.textLabel.text = ...some text
  
    //set row as container for two cells    
    UITableViewCell *twoColumnRowView = [[UIView alloc] init]; //initWithFrame:CGRectMake(0, 0, 200, 20)];
  
    cell1.contentView.frame = CGRectMake(0, 0, 100, 20);
    [twoColumnRowView addSubview:cell1];
    cell2.contentView.frame = CGRectMake(100, 0, 100, 20);
    [twoColumnRowView addSubview:cell2];
  
    return twoColumnRowView; // cell;
  }
  </code></pre>
  
  <p>It's just a raw prototype I'm playing with now. But the code crashes at runtime with "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setTableViewStyle:]: unrecognized selector sent to instance"</p>
  
  <p>UPDATE 2. I have changed a code to look more practical. Strange but after several tries I got the app working without crash but with weird black background in all cells. Here is the code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
    static NSString *FirstCellIdentifier = @"FirstCellIdentifier"; 
    static NSString *SecondCellIdentifier = @"SecondCellIdentifier";
  
    // initialize first cell
    UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:FirstCellIdentifier];
  
    if (cell1 == nil) {
      cell1 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstCellIdentifier] autorelease];
    }
  
    //initialize second cell
    UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:SecondCellIdentifier];
  
    if (cell2 == nil) {
      cell2 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SecondCellIdentifier] autorelease];
    }
  
    cell1.textLabel.text = ...data
    cell2.textLabel.text = ...data
  
    UITableViewCell *twoColumnRowView = [[UITableViewCell alloc] init];
  
    [twoColumnRowView addSubview:cell1];
    //cell2.contentView.frame = CGRectMake(100, 0, 100, 20);
    [twoColumnRowView addSubview:cell2];
  
    return twoColumnRowView; // cell;
  }
  </code></pre>
  
  <p>I'm not reusing twoColumnRowView but both other does do.</p>