UITextView's selectedRange Is Inaccurate when UIKeyboardWillShowNotification Is Posted

Number:rdar://15149060 Date Originated:10/3/2013
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 7
Classification:Bug Reproducible:YES

The tap that makes the UITextView become first responder causes UIKeyboardWillShowNotification to get posted -- but before UITextView has updated its selectedRange property.

This is a problem because you might want to scroll the UITextView to show the selectedRange -- you might want to make sure the typing is visible to the user. (See #15148548: UITextView doesn't scroll to show typing.)

If you get the selectedRange on the next turn of the run loop, it will be accurate -- but you won't be able to properly sync your scrolling animation with the animation of the keyboard appearing.

Steps to Reproduce:

See the attached project that demonstrates the bug.

Expected Results:

selectedRange is correct when UIKeyboardWillShowNotification is posted.

Actual Results:

selectedRange is not correct when UIKeyboardWillShowNotification is posted.

iOS 7

'TVKeyboardSelectionBug.zip' was successfully uploaded.


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!