title: View rendering in iOS 4.2
body: <p>I built a custom view to make chat messages according to <a href="http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-custom-chat-view-and-emoticons/." rel="nofollow">this tutorial</a></p>
  
  <p>It is working fine if the app is directly compiled on device.But while creating an ipa file and installing it via iTunes, in iOS 4.2, the height of the chat bubbles are stretched more than the required size and causes overlapping of chat bubbles. But it is working fine in iOS 5.What would be the reason for this?Thanks in advance.</p>
  
  <p>EDIT:</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      NSDictionary *dict = (NSDictionary *)[messages objectAtIndex:indexPath.row];
      NSString *msg = [[dict objectForKey:@"message"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  
      CGSize  textSize = { 260.0, 10000.0 };
      CGSize size = [msg sizeWithFont:[UIFont boldSystemFontOfSize:13]
                    constrainedToSize:textSize
                        lineBreakMode:UILineBreakModeWordWrap];
  
      size.height += padding*3;
  
      CGFloat height = size.height &lt; 65 ? 65 : size.height;
      return height;
  
  }
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"MessageCellIdentifier";
  
      SMMessageViewTableCell *cell = (SMMessageViewTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if (cell == nil) {
          cell = [[[SMMessageViewTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      }
  
  
      if ([messages count]&gt;0) {
          NSLog(@"index path is %d",indexPath.row);
  
      NSDictionary *s = (NSDictionary *) [messages objectAtIndex:indexPath.row];
  
  
      NSString *sender =allTrim([s objectForKey:@"sender"]);
      NSString *senderId = [s objectForKey:@"friendId"];
      NSString *message = [s objectForKey:@"message"];
          if ([message length]&lt;8)
          {
              message=[message stringByAppendingString:@"  "];
          }
      message=[message stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  
      NSString *time = [s objectForKey:@"time"];
      NSString *locatn = [s objectForKey:@"friendLocation"];
  
      CGSize  textSize = { 260.0, 10000.0 };
      CGSize size = [message sizeWithFont:[UIFont boldSystemFontOfSize:13]
                        constrainedToSize:textSize
                            lineBreakMode:UILineBreakModeWordWrap];
  
      size.width += (padding/2);
  
      cell.messageContentView.text = [message stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
      cell.accessoryType = UITableViewCellAccessoryNone;
      cell.userInteractionEnabled = YES;
          cell.selectionStyle=UITableViewCellSelectionStyleNone;    
      UIImage *bgImage = nil;
  
      if ([senderId isEqualToString:UIAppDelegate.userId]) { 
  
          sender=@"Me";
  
          bgImage = [[UIImage imageNamed:@"ChatBubbleGray.png"] stretchableImageWithLeftCapWidth:24  topCapHeight:15];
  
          [cell.messageContentView setFrame:CGRectMake(padding, padding*2, size.width, size.height)];
  
          [cell.bgImageView setFrame:CGRectMake( cell.messageContentView.frame.origin.x - padding/2,
                                                cell.messageContentView.frame.origin.y - padding/2,
                                                size.width+padding,
                                                size.height+padding)];
          cell.senderAndTimeLabel.textAlignment=UITextAlignmentLeft;
  
      } else {
  
  
          bgImage = [[UIImage imageNamed:@"ChatBubbleGreen.png"] stretchableImageWithLeftCapWidth:24  topCapHeight:15];
  
          [cell.messageContentView setFrame:CGRectMake(320 - size.width - padding,
                                                       padding*2,
                                                       size.width,
                                                       size.height)];
  
          [cell.bgImageView setFrame:CGRectMake(cell.messageContentView.frame.origin.x - padding/2,
                                                cell.messageContentView.frame.origin.y - padding/2,
                                                size.width+padding,
                                                size.height+padding)];
          cell.senderAndTimeLabel.textAlignment=UITextAlignmentRight;
  
  
      }
      cell.bgImageView.image = bgImage;
      if ([locatn length]&gt;0)
      {
          cell.senderAndTimeLabel.text = [NSString stringWithFormat:@"%@, %@   %@", sender, locatn, time];
  
      }
      cell.senderAndTimeLabel.text = [NSString stringWithFormat:@"%@,   %@", sender, time];
      }
      return cell;
  }
  </code></pre>