Affordable custom keyboard in iOS

I want a custom keyboard to run like an iOS software keyboard in terms of accessibility. When a button click adds a letter to the UITextField, the letter should be spoken by VoiceOver in the "added character tone". When a button click removes a letter from the UITextField, the letter must be spoken by VoiceOver in the "deleted character".

Here is what I tried:

  • Created a UITextField in the storyboard view controller.
  • Two UIButtons are created with the Type and Backspace caption in the storyboard view controller.
  • Set accessibility properties for UIButtons for Keyboard Key.
  • Captured the UITextField storyboard before the UITextField IBOutlet instance, textField.
  • Captured the storyboard "Type UIButton to IBAction", type.
  • Captured the storyboard "Backspace UIButton" to IBAction, -backspace.
  • Implemented -type as: [[self textField] insertText:@"a"]; .
  • Implemented -backspace as: [[self textField] deleteBackward]; .
  • Made textField the first responder.

I also tried the same thing by moving buttons in a UIView that was set as textFields inputView.

Characters are correctly added and removed from the text box, but VoiceOver does not speak. How can I do this job?

EDIT:
The hardware keyboard speaks correctly. Only the user keyboard of the software does not speak as it should.

+5
source share
2 answers

This device may require Voice Over. You can change this in availability. I'm not sure what to do if a voice over device is already on on the device.

0
source

I noticed that in order for "Conversational Content", "Talk on Screen" to also speak on the keyboard keys, I had to add .keyboardKey to the accessibilityTraits button, for example, in Swift:

 button.accessibilityTraits = [.keyboardKey] 

Or in Objective-C:

 [button setAccessibilityTraits:UIAccessibilityTraitKeyboardKey]; 

And, obviously, if your buttons are images, you'll also want to add an explicit accessibilityLabel for them.

0
source

Source: https://habr.com/ru/post/1482413/


All Articles