Delete (not Backspace) doesn't fire UITextViewDelegate's shouldChangeTextInRange
Asked Answered
K

1

9

When using an external keyboard, my UITextView fires a shouldChangeTextInRange message just fine when I press the Backspace key ("backward delete"), but if I press Delete ("forward delete") then the method is never called at all, despite the view's text changing as expected. In case it matters, I'm using Swift and the latest iOS simulator.

If this is expected behavior, can someone point me to the documentation that explains it?

More importantly, is there a workaround?

Edit: submitted rdar://18909378. I've also discovered the same behavior when using cmd+backspace and opt+backspace. Very annoying!

Karleenkarlen answered 6/11, 2014 at 17:17 Comment(3)
Please file a radar to report the issue to bugreport.apple.com and edit your question to include the radar number in case someone else wants to reference it.Aviles
Also experienced this and submitted rdar://20252668 in the hope that this will be sorted soonShiny
Same issue with UITextField.Counterweight
F
1

I'm still seeing this issue on iOS 10. The best workaround I've come up with is to listen to the field's UIControlEventEditingChanged event and grab textField.text from there. This gives you the updated contents, but doesn't allow you to prevent the delete action like shouldChangeCharactersInRange does.

Fabricate answered 9/12, 2016 at 15:16 Comment(1)
Submitted rdar://29595896: "UITextField doesn't call shouldChangeCharactersInRange in response to a forward delete" which was close as duplicate of rdar://24966189 (still Open).Fabricate

© 2022 - 2024 — McMap. All rights reserved.