Autocorrect selection indicator does not update

Originator:matej
Number:rdar://19564341 Date Originated:22-Jan-2015 06:05 PM
Status:Closed Resolved:
Product:iOS Product Version:8.1.2
Classification:UI/Usability Reproducible:Always
 
Summary:

The system autocorrect selection indicator fails to update it’s position and size in some cases. One simple example is a configuration where a UITextView is embedded in another UIScrollView. If we have an autocorrect selection window currently visible and scroll the outer scroll view, the selection does not update (this worked on iOS 7, but does not on iOS 8). A similar problem occurs if we, for instance, change the text size while the autocorrect selection is visible. The selection window does not resize to match the new text frame (happens on iOS 7 as well). Changing the text view frame also brakes layout. 

Steps to Reproduce:

Run the attached sample project. 
Write some misspelled text in the orange text view to trigger the autocorrect selection indicator. 
Scroll the outer (white) scroll view or press the resize button below the text view while the autocorrect indicator is visible. 

Expected Results:

The autocorrect view would match the text position. 

Actual Results:

The autocorrect view stays at its original position and does not resize.

Regression:

iOS 8.1.2, some problems are also apparent on iOS 7. Happens on iPhone and iPad. 

Notes:

Scroll (GIF): http://cl.ly/image/433j3w090X28
Resize before: http://cl.ly/image/3o2M373C0v42
Resize after: http://cl.ly/image/400o110H2W0w

Also please see the attached sample project.

Comments

Refined workaround

The above workaround has a significant impact on scroll view performance. An alternative is to force autocorrection to disappear when scrolling starts.

// Category on UITextView

  • (void)dismissAutocorrectSuggestion { NSRange range = self.selectedRange; NSString *text = self.text; self.text = @""; [self setText:text]; [self setSelectedRange:range]; }

Workaround

A possible workaround is to send [self.textView.inputDelegate textWillChange:self.textView]; and [self.textView.inputDelegate textDidChange:self.textView]; when the text view / scroll offset change. See the updated sample project. http://cl.ly/1B381v133g2p

Sample project

http://cl.ly/133P3V0q080A


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!