Dismiss a UIKeyboardTypeNumberPad in a UITextField when VoiceOver is active?

柔情痞子 提交于 2019-12-11 11:10:09

问题


How do I dismiss a UITextField with keyboard type UIKeyboardTypeNumberPad? The accepted answer to this question suggests to either add a bar with a dismiss button as an inputAccessoryView or to listen to touch events on the background.

I prefer the second approach, i.e. listen to touch events on the view containing the UITextField. However, this approach fails if VoiceOver is active. How do you resignFirstResponder in that situation?


回答1:


You need an alternative way to perform the gesture. You'll have to add a button to your layout. Sorry...

You should be able to check whether VoiceOver is on or not.

BOOL UIAccessibilityIsVoiceOverRunning();

You could also consider adding a tap recognizer to an invisible UI Element or a parent View that is completely covered with other elements. In this way, it would only be able to be activated by a VoiceOver user.



来源:https://stackoverflow.com/questions/30872419/dismiss-a-uikeyboardtypenumberpad-in-a-uitextfield-when-voiceover-is-active

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