iOS 7: UITextView scrolls strangely when created using Interface Builder

Originator:robotspacer
Number:rdar://16375664 Date Originated:19-Mar-2014 11:35 PM
Status:Open Resolved:
Product:iOS SDK Product Version:7.0 and 7.1
Classification:Other Bug Reproducible:Always
 
Summary:
A UITextView created using Interface Builder shows some strange scrolling behavior, particularly when dismissing the keyboard, and then adjusting the text view. The view scrolls much more than it needs to. When a visually identical UITextView is created through code, the problem is gone.

Steps to Reproduce:
1. Open the attached project Text1. This version has a UITextView included in the Storyboard, created through Xcode's Interface Builder.
2. Build and run the app. The bug is present in the simulator as well as on a device.
3. Scroll down in the text view, and tap next to "In a row", for example.
4. Wait for the keyboard to appear, then tap "Done".

Expected Results:
The text view should appear exactly how it did before the keyboard was shown. The text "In a row" should still be on screen.

Actual Results:
The view is scrolled up much higher than necessary. The words "In a row" are far off screen.

Version:
7.0 and 7.1

Notes:
I've also included a project Text2, showing the bug is not present when the UITextView is created in code. There's a comment pointing out one line in particular—the creation of the NSTextContainer. If initWithSize: is given CGSizeZero instead of frame.size, it behaves the same way as the Text1 project. Hopefully that's useful in finding the cause of the bug.

Attachment:
http://junecloud.com/journal/bugs/uitextview.zip

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!