UILabel vertical sizing, text truncation, UITableViewHeaderFooterView, readableContentGuide

Originator:jbrayton
Number:rdar://28337748 Date Originated:09-15-2016
Status:Open Resolved:
Product:iOS (UIKit) Product Version:iOS 10.0.1 (14A403), Xcode 8.0 (8A218a)
Classification:UI/Usability Reproducible:Always
 
The attachments to this radar are available at:
https://www.dropbox.com/sh/itxsdml0m9vtt6b/AACiMkvOKT7atxsYhLWVZirHa?dl=0


I am seeing unexpected text truncation when a UILabel is embedded in a UITableViewHeaderFooterView and vertically constrained to the readableContentGuides of the UITableViewHeaderFooterView. 

These conditions must be met in order to reproduce the problem:

1.  The UITableView must use self-sizing header/footer views.
2.  The UILabel must be embedded in a UITableViewHeaderFooterView.
3.  The UILabel must have numberOfLines set to 0.
4.  The text of the UILabel must have a hard line break in it. For example, "first of two lines\nsecond of two lines". (I see similar issues that are not as easily reproducible if the text is long but does not have a hard line break.)
5.  The topAnchor of the UILabel must be constrained to the topAnchor of the readableContentGuide of the UITableViewHeaderFooterView.
6.  The bottomAnchor of the UILabel must be constrained to the bottomAnchor of the readableContentGuide of the UITableViewHeaderFooterView.
7.  The UITableViewHeaderFooterView must be created when it is scrolled into view. I do not see the behavior on UITableViewHeaderFooterView objects shown initially and never scrolled out of view.
8.  The app must be compiled by Xcode 8 against the iOS 10 SDK.

The problem I see is that the height of the UILabel is too small and the text is truncated even though numberOfLines on the UILabel is set to 0 and the sizing of the label and footer should be automatic.

I attached a sample project that demonstrates the issue.


Steps to Reproduce:

1.  Open the attached sample project.

2.  Observe that TableViewController has a viewForFooterInSection method that returns a UITableViewHeaderFooterView, and that the footer view should display the following text:

	first of two lines
	second of two lines

3.  Run the attached project.

4.  Observe that the initially visible footers display the text above as expected.

5.  Scroll all the way down to the bottom and then scroll back to the top.


Expected Results:

All footers should display the following text:

	first of two lines
	second of two lines


Actual Results:

Section footers created while scrolling show the following text:

	first of two lines…

The second line of text is not visible.


Configuration:  

I see this on my iPhone 5S. I also see this in the simulator.

Version & Build:  

iOS 10.0.1 (14A403), Xcode 8.0 (8A218a)

Additional Notes:

I believe the problem does not occur when the same code is compiled against the iOS 9.3 SDK but run on iOS 10. I encountered this problem when updating an app for iOS 10, and had not seen the problem on iOS 10 when the app was compiled against the iOS 9.3 SDK. However, I did not confirm this with the sample project.

Comments

Workaround

My workaround is simply to avoid using vertical readable content guide anchors in header views and footer views. They don't appear to be as important as horizontal readable content guide anchors.


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!