title: UITableViewCell: Dynamic Cell Height by 'Cell Identifier'
body: <p>(note: The tableView I am using is from the Parse.com iOS SDK - PFQueryTableViewController)</p>
  
  <p><strong>Scenario</strong> = I have a TableViewController that has two different types of cells (each with their own identifier). Each object upon being queried and loaded into the datasource is checked if a key on the object is true. Depending on the result I dequeueReusableCellWithIdentifier to the correct cell.</p>
  
  <pre><code>-(PFTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
  
      myTableViewCell *cell;
  
      if ([object[@"orientation"] isEqualToString:@"left"] || [object[@"orientation"] isEqualToString:@"right"]) {
  
          myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
  
      else {
  
          myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell2"];
      }
  </code></pre>
  
  <p>This all does its job. Each cell is being loaded at the correct indexPath.row and everything. Problem is my tableView "Row Height" itself does not readjust for the new cell. This causes overlapping of cells and makes everything ugly. I can tell the tableView in storyboard to set the row height to whatever the larger of the two cell heights is, but that leaves big spaces in-between cells too which also makes it look ugly.</p>
  
  <p><strong>Question</strong> = It is my belief (and correct me if I'm wrong) that I need to use the</p>
  
  <pre><code>-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  </code></pre>
  
  <p>method in order to achieve this. Where I need help is I am not sure how to set the height of each cell at indexPath depending upon the 'identifier' that I gave each cell in the cellForRowAtIndexPath method.</p>
  
  <p><strong>What I'm looking for</strong> = Something like this (please excuse the SuedoCode)</p>
  
  <pre><code>-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      if ([cell.identifier isEqual:@"Cell"] {
  
      return 100;
  
      }
  
      else {
  
      return 200;
  
      }
  }
  </code></pre>
  
  <p><strong>ANSWER: I figured it out!</strong> (I marked the answer below as accepted because it pointed me in the right direction)</p>
  
  <p>Because I am using a PFQueryTableViewController all I had to do this...</p>
  
  <pre><code>-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      PFObject *object = [self.objects objectAtIndex:indexPath.row];
  
      if ([object[@"orientation"] isEqual:@"left"] || [object[@"orientation"] isEqual:@"right"]) {
  
          return 100;
      }
  
      else {
  
         return 200;
      }
  
  }
  </code></pre>