UITextView display bug inside custom UITableViewCell but not in a custom UIView

Originator:king7532
Number:rdar://21326124 Date Originated:10-Jun-2015 12:52 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8.3 and 9.0 (beta)
Classification:Serious Bug Reproducible:Always
 
Summary:
I have a custom UITableViewCell with a UITextView and using constraints to pin it to all 4 sides of the cell's contentView with an initial heigh of 21. I am key value observing the UITextView's contentSize, so when a user creates a new line (i.e. presses enter) or removes a line (i.e. backspacing to the previous line) I change the height of the UITextView to the new intrinsic height in my KVO observer callback.

However, the same UITextView code behaves differently in a custom UITableViewCell compared to a UIView. In the UITableViewCell the first line of text scrolls out of view for every even line of text added but not every odd line! This does not happen in the custom UIView.

Steps to Reproduce:
I have included a sample Xcode project called MyTableViewCells with 2 iOS targets:
* MyTableViewCells -- Contains a custom UITableViewCell called BasicTextViewCell that contains a UITextView with yellow background
* NoTable -- Contains a custom UIView called ContainerView that contains a UITextView with yellow background

Also available on Github:  https://github.com/king7532/MyTableViewCells

Expected Results:
The UITextView should not scroll the first line of text out of view for each even line added. UITextView should behave the same in a custom UIView or UITableViewCell.

Actual Results:
The first line of text scrolls out of view for every even line of text added but not every odd line. This does not happen in the custom UIView.

Version:
Deployment target iOS 8.3
* iOS Simulator - iPhone 6 with iOS 8.3 (12F69) - Xcode 6.3.2 (6D2105)
* iOS Device - iPhone 6 with iOS 8.3 (12F70)

Deployment target iOS 9.0 (beta)
* iOS Simulator - iPhone 6 with iOS 9.0 (13A4254u) - Xcode 7.0 beta (7A120f)

Notes:
I showed this bug to many Apple Engineers at #WWDC15 and Luke from UIKit confirmed it’s a bug, probably a positioning bug between UITextView and it’s UITextContainer?

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!