title: Custom UITableViewCell and slow Scroll
body: <p>i need two kinds of UITableViewCell that has different height:</p>
  
  <p>a) One with a small UIImageView holding user picture, 3 UILabel's and one UIImageView of 200 x 100.</p>
  
  <p>b) The other has the same like a) without the UIImageView. </p>
  
  <p>Well, in order to achieve this i have built two custom UITableViewCell's and set my UITableView to use them.</p>
  
  <p>The problem is when i scroll the table because sometimes it isn't smooth. </p>
  
  <p>My code is the following (i only post the cellForRowAtIndexPath)</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if (.....) return HEIGHT1 
      else return HEIGHT2
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"CheckinCellIdentifier";
      static NSString *TextCellIdentifier = @"CheckinTextCellIdentifier";
      CheckIn *checkin = [self.checkinArray objectAtIndex:indexPath.row];
  
      if (checkin.photoUrl) {
  
          CheckinUITableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
          if (cell == nil){
              NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CheckinUITableViewCell" owner:nil options:nil];
  
              for(id currentObject in topLevelObjects) {
                  if([currentObject isKindOfClass:[CheckinUITableViewCell class]]) {
                      cell = (CheckinUITableViewCell *)currentObject;
                      if (self.userImage)
                          cell.userImage.image = self.userImage;
                      break;
                  }
              }
          }
  
          cell.checkin = checkin;    
          UIImage *imageCheckin = [self.checkinImages objectForKey:[NSNumber numberWithInt:checkin.checkInId]];
          if (imageCheckin) {
              cell.checkinImage.image = imageCheckin;
          } else {
              CompleteBlock block = ^(NSData* imageData) {
                  if (imageData) {
                      UIImage *image = [UIImage imageWithData:imageData];
                      [self.checkinImages setObject:image forKey:[NSNumber numberWithInt:checkin.checkInId]];
                      CheckinUITableViewCell *lookedUpCell = (CheckinUITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
                      if (lookedUpCell){
                          cell.checkinImage.image = image;
                          //[lookedUpCell setNeedsLayout];
                      }
                  }
              };
              [Utility loadImageFromFile:checkin.photoPath url:checkin.photoUrl withCompletionBlock:block];
          }
          return cell;
      } else {
          CheckinTextUITableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:TextCellIdentifier];
          if (cell == nil){
              NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CheckinTextUITableViewCell" owner:nil options:nil];
  
              for(id currentObject in topLevelObjects) {
                  if([currentObject isKindOfClass:[CheckinTextUITableViewCell class]]) {
                      cell = (CheckinTextUITableViewCell *)currentObject;
                      if (self.userImage)
                          cell.userImage.image = self.userImage;
                      break;
                  }
              }
          }
          cell.checkin = checkin;    
          return cell;
      }
  
  }
  </code></pre>
  
  <p>Any idea? Thanks!</p>