UITableViewCell dynamic self sizing doesn't appear to work with UILabel content
| Originator: | rnystrom | ||
| Number: | rdar://17995000 | Date Originated: | 8/12/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 8 Beta 5 |
| Classification: | Reproducible: | Yes |
Summary:
When setting Auto Layout constraints on UILabels within UITableViewCells, automatic cell sizing does not appear to be working as advertised. Once you scroll the UITableView the cells appear to layout appropriately. First-pass sizing and orientation changes seem to break cell sizes.
Also, the only way I can get UILabels contained in UITableViewCells to respond to width changes is to override UITableViewCell's layoutSubviews and set the UILabel's preferredMaxLayoutWidth manually.
Steps to Reproduce:
1. Use a UITableViewController
2. Set the tableView's rowHeight to UITableViewAutomaticDimension
3. Setup a UITableViewCell prototype with a UILabel that has top and bottom constraints with the cell's contentView
4. Run and don't scroll
5. Scroll to see labels expand and cells resize
6. Change orientation to see incorrect cell sizing
Expected Results:
UILabels should not truncate ("...") when numberOfLines is set to 0 and top and bottom constraints are setup.
Actual Results:
UILabels truncate and the UITableViewCell is not the appropriate height.
Version:
iOS 8 Beta 5
Notes:
Configuration:
Tested on iPad & iPhone simulator, iPad Air, iPhone 5
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
You missed a step: Set the tableView's estimatedRowHeight