title: IOS calculate tableview row height for custom cells
body: <p>I have an application that uses tableviews on every screen. I have plenty of custom cells, each having different height. Right now calculating the height is quite a challenge. I am looking for a generic method that will return the height for each custom cell without using heightForRowAtIndex. The reason I don't want to use heightForRowAtIndex because I have 4 xibs behind one cell and I don't want to mess this metho with <code> if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {} </code> kind of checks. For the record cell xibs are both iPhone, iPad with english and arabic versions:
  <br/>cell_en.xib<br/>
  cell_en~ipad.xib<br/>
  cell_ar.xib<br/>
  cell_ar~ipad.xib<br/></p>
  
  <p>Currently, I am trying following;</p>
  
  <pre>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
              {
                  switch (indexPath.row) {
  
                  case 0:
                  {
                      VPCell1 *cell=[VPCell1 cellForTable:tableView withOwner:self];
                      [tableView setRowHeight:CGRectGetHeight(cell.contentView.frame)];
                      return cell;
                  }
                  case 1:
                  {
                      VPCell2 *cell=[VPCell2 cellForTable:tableView withOwner:self];
                      [tableView setRowHeight:CGRectGetHeight(cell.contentView.frame)];
                      return cell;
                  }
                  case 2:
                  {
                      VPCell3 *cell=[VPCell3 cellForTable:tableView withOwner:self];
                      [tableView setRowHeight:CGRectGetHeight(cell.contentView.frame)];
                      return cell;
                  }
            }
      }
  
  </pre>
  
  <p>Here I am using <code>[tableView setRowHeight:CGRectGetHeight(cell.contentView.frame)];</code>
  to set row height for each cell.<br/>
  Turns out setRowHeight method should be used, iff all cells inside a tableview have same height so definitely not a choice here for performance optimization. I am open to ideas to solve this mess.
          <br/>Thanks!</p>