title: Multi-line UILabel omits last line sometimes iOS
body: <p>I am using a multi-line UILabel in a tableview cell with dynamic height. The problem is sometimes, the UILabel omits the last line while the label height is perfect and sometimes it displays everyline perfectly. This is similar to this problem but I have checked that the number of lines are not changing in my case.</p>
  
  <p><a href="https://stackoverflow.com/questions/7252428/uilabel-does-not-show-all-my-text-and-it-also-doesnt-show-that-there-is-more">UILabel does not show all my text and it also doesn&#39;t show that there is more (...)</a></p>
  
  <p>I am implementing UILabel by </p>
  
  <ol>
  <li>set lines to 0</li>
  <li>set word wrap</li>
  </ol>
  
  <p>I then set the text in the Label. </p>
  
  <p>This is the screenshot. The first cell second label shows complete text while the 3rd cell second label does not while the label height is perfect.</p>
  
  <p><img src="https://i.stack.imgur.com/JEJFg.png" alt="enter image description here"></p>
  
  <p>This is the case whether it is a long text of 13-14 lines or just 2 lines. Only the last line is omitted and that too sometimes.</p>
  
  <p>I have also set the preferred width of each of these labels to 220 in nib file of my table view cell.</p>
  
  <p>My code:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
  
  
  
  Message *message = [self.messages objectAtIndex:indexPath.row];
  
  if(indexPath.row % 2 != 0 || indexPath.row == 10)
  {
      chatCell = (ChatTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"chatSend"];
  
      [chatCell.chatMessageLabel setNumberOfLines:0];
      [chatCell.chatNameLabel setNumberOfLines:0];
      [chatCell.chatTimeLabel setNumberOfLines:0];
  
  
      chatCell.chatMessageLabel.lineBreakMode = NSLineBreakByWordWrapping;
      chatCell.chatNameLabel.lineBreakMode = NSLineBreakByWordWrapping;
      chatCell.chatTimeLabel.lineBreakMode = NSLineBreakByWordWrapping;
  
      chatCell.chatMessageLabel.text=message.message;
      chatCell.chatNameLabel.text = message.name;
      chatCell.chatTimeLabel.text = message.time;
      chatCell.chatUserImage.image = message.avatar;
  
  
  
  }
  else
  {
      chatCell = (ChatTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"chatReceive"];
  
  
  
      [chatCell.chatMessageLabel setNumberOfLines:0];
      [chatCell.chatNameLabel setNumberOfLines:0];
      [chatCell.chatTimeLabel setNumberOfLines:0];
  
      chatCell.chatMessageLabel.lineBreakMode = NSLineBreakByWordWrapping;
      chatCell.chatNameLabel.lineBreakMode = NSLineBreakByWordWrapping;
      chatCell.chatTimeLabel.lineBreakMode = NSLineBreakByWordWrapping;
  
      chatCell.chatMessageLabel.text=message.message;
      chatCell.chatNameLabel.text = message.name;
      chatCell.chatTimeLabel.text = message.time;
      chatCell.chatUserImage.image = message.avatar;
  
  
  
      chatCell.authorType = STBubbleTableViewCellAuthorTypeOther;
  
  }
  
  
      return chatCell;
  }
  </code></pre>
  
  <p>Kindly help!!</p>