Is there any way refresh cell's height without reload/reloadRow?

前端 未结 4 1077
忘掉有多难
忘掉有多难 2021-01-31 09:41

I make a view like imessage, just input text into the bottom text view. I use table view to do this, and the text view in the last cell. when I input long text that more than on

4条回答
  •  长情又很酷
    2021-01-31 10:30

    Check out this library. This is an implementation of message bubbles using UITableView. Keep in mind that every time a cell is displayed, cellForRow:atIndexPath is called and the cell is drawed.

    EDIT

    You can use heightForRowAtIndexPath

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        Messages *message = [self.messageList objectAtIndex:[indexPath row]];
        CGSize stringSize = [message.text sizeWithFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:13]
                                        constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:UILineBreakModeWordWrap];
        return stringSize.height + 78;
    }
    

提交回复
热议问题