edit: I think this may have something to do with iOS 8.3. This doesn't occur on the simulator and none of my testers have the problem but my dev phone with 8.3 on it does. Any ideas on how to fix it?
edit2: I found an answer here https://stackoverflow.com/a/36711109/1552116. I've answered this SO below and will accept in 2 days but I guess this is technically a duplicate?
I have a UITableView
with rowHeight set to UITableViewAutomaticDimension
Each cell contains multiple labels, one of which can be multi line. Sometimes, the cell displays correctly with the label taking up multiple lines. Other times, the cell is sized correctly but the label only takes up one line, leaving a big empty space where the other lines should have gone.
The tableview is backed by a NSFetchedResultsController
.
Picture to show what I mean (to be clear "Expected" is not a rendering, it's an actual screenshot of the app working some of the time)
Things I've tried + Thoughts
There's a refresh action on the page and I've tried tableView.reloadData()
, tableView.setNeedsLayout()
and both don't seem to help
I've noticed if I'm on the tableView when the notification is created, it displays correctly. If I force quit the app (or run the app again from XCode) and the cells are initialized from the fetch result, then they get displayed erroneously.
This app is also on testflight
and of the ~5 testers we have none of them have reported the issue.
Edits Answering comments
Code that sets the label cellForRowAtIndexpath
let cell = tableView.dequeueReusableCellWithIdentifier(StoredNotificationViewController.snTableViewCellReuseIdentifier, forIndexPath: indexPath) as! StoredNotificationTableViewCell
configureCell(cell, atIndexPath: indexPath)
configureCell
let storedNotification = snFetchedResultsController.objectAtIndexPath(indexPath) as? StoredNotification
cell.setData(storedNotification)
cell.setData
messageLabel.text = notification.message