VoiceOver with Custom Keyboard

℡╲_俬逩灬. 提交于 2019-12-10 22:25:55

问题


I have a custom keyboard app and currently am working on a voice over support update, but am having an issue with the delete (backspace) button.

My keyboard is now working exactly like the apple default keyboard with Voice Over in "Touch Typing" mode. When the user taps on w, a, s then space, VoiceOver will say "was" after the space button is tapped. Myb only issue is with the delete key, when the user taps on it, VoiceOver says "Bottom of documnet" rather than the deleted character. I have tried many different ways to allow VoiceOver to speak the deleted word, but no luck.

My delete key' accessibilityTraits is set to

button.accessibilityTraits =  UIAccessibilityTraitKeyboardKey  

just like the other keys in the keyboard, but that is not helping.

What I need is for VoiceOver to say what is being deleted when the delete key is pressed just like the Apple keyboard does wit VoiceOver.

Many thanks Hassan


回答1:


I was able to figure out the solution for this issue. First of all I used the UIAccessibilityAnnouncementNotification which will be called when the delete button is pressed and will pass the deleted character to it as a parameter. We find the deleted character by using textDocumentProxy.documentContextBeforeInput this will return a string and all you need to do is to get the last character.

Done!!!!! Easy solution for an annoying issue.



来源:https://stackoverflow.com/questions/43585145/voiceover-with-custom-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!