Question

I’m trying to figure out how to make a non-UITextField class that conforms to the UIKeyInput protocol announce the typed and deleted characters with VoiceOver, just as UITextField does. It should speak each character that is typed in a slightly lower tone and each character that is deleted in a much lower tone.

I don’t want to use UITextField because:

  1. The user mustn’t be able to select the text.
  2. The user mustn’t be able to change the position of the “cursor.”
  3. There must be no autocorrection.
  4. The text field must not announce, “Text field is editing.”
  5. I don’t want any of the other side effects of UITextField.
  6. The text field is a custom view.

Essentially I’m looking to do what the Keyboard tab of the Phone app on iPhone does. I tried conforming the class to the UITextInput protocol, but it didn’t make a difference.

Was it helpful?

Solution

As it turns out, I wasn’t correctly implementing the UITextInput protocol methods.

The methods that affect the speaking of typed/deleted letters are:
-textInRange:
-textRangeFromPosition:toPosition:

The properties that affect the speaking of typed/deleted letters are:
selectedTextRange
beginningOfDocument
endOfDocument

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top