I am using multiline UILabel in a tableview cell with dynamic height. Sometimes the problem is that UILabel skips the last line, while the height of the label is perfect, and sometimes it perfectly displays each line. This seems like this problem, but I checked that the number of rows in my case does not change.
UILabel does not display all text, nor does it show that there is more (...)
I am implementing UILabel with
- set lines to 0
- set word wrap
Then I set the text in the shortcut.
This is a screenshot. The first label of the second cell shows the full text, while the second label of the third cell does not work when the height of the label is perfect.

This is the case if it is a long text of 13-14 lines or just 2 lines. Only the last line is omitted, and this is also sometimes.
I also set the preferred width of each of these labels to 220 in the nib file of my table view cell.
My code is:
- (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; }
Please help !!
source share