I have a custom UITableViewCell subclass which has had autolayout constraints applied to it in Interface Builder. The cell contains multiple views, including a
In accordance to this multiple lines UILabel GitHub issue, this is a lingering iOS bug.
I found that in iOS 9+, this situation mostly occurs in editing mode, with much unpredictability.
The following workaround only partially works: it requires redrawing the UITableView twice, and still does not cover all scenarios.
override func viewDidLoad() {
super.viewDidLoad()
tableView.setNeedsLayout()
tableView.layoutIfNeeded()
tableView.reloadData()
}
Notes:
UITextView is a great alternative to multiple line UILabel, without the bug. UITextView does not exhibit any of the IULabel other oddities either, like alignment errors or flickering.self.tableView.editing is truetableView.estimatedRowHeight reduces the occurrence