0
votes

I'm working with a table view that has a lot of changes coming in. Because of this I have to avoid reloading the whole thing, or even single cells because it becomes difficult to scroll, and keeps jumping around with all the stuff that is changing. I figured out how to update a single label, and this doesn't affect other user's scroll position or cause bouncing/jumping of the tableview. The problem I am having is that wordwrap doesn't seem to work when I do this. I have lines set to 0 and wordwrap turned on and it works fine any other way (with reloadData()) but if I just change the label, it just keeps going on the same line. This is how I update the label:

if let cell = self.tableView.cellForRowAtIndexPath(NSIndexPath(forRow: index, inSection: 0)) as? customCell {
     cell.textLabel.text = newText as? String
}

This properly updates the label within the custom cell very smoothly, I just can't figure out how to get it to wordwrap. I tried sizeToFit(), and also beginUpdates / endUpdates, and with begin/end updates it actually works, but it causes some issues with the table jumping again. (similar to reloadData()). Thank you for taking the time to read this, and I am open to any suggestions.

***** Update *****

It looks like the label isn't able to wordwrap because the cell height doesn't change, that's why beginUpdates/endUpdates works. If I update the cell height though the whole table jumps up and down and everything just gets crazy. I want this label to not disrupt everything else.

1

1 Answers

0
votes

Check the height constraint of the lable... give height constraint as >= some value.

For ex: height >= 20