当VoiceOver处于活动状态时,关闭UITextField中的UIKeyboardTypeNumberPad吗? [英] Dismiss a UIKeyboardTypeNumberPad in a UITextField when VoiceOver is active?
问题描述
如何关闭键盘类型为UIKeyboardTypeNumberPad
的UITextField
?对此问题的可接受的答案建议添加带有关闭按钮的栏作为
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.
我更喜欢第二种方法,即在包含UITextField
的视图上监听触摸事件.但是,如果VoiceOver处于活动状态,则此方法将失败.在这种情况下,您如何resignFirstResponder
?
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?
推荐答案
您需要另一种执行手势的方法.您必须在布局中添加一个按钮.抱歉...
You need an alternative way to perform the gesture. You'll have to add a button to your layout. Sorry...
您应该能够检查VoiceOver是否打开.
You should be able to check whether VoiceOver is on or not.
BOOL UIAccessibilityIsVoiceOverRunning();
您还可以考虑将拍击识别器添加到不可见的UI元素或完全被其他元素覆盖的父视图中.这样,它只能由VoiceOver用户激活.
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.
这篇关于当VoiceOver处于活动状态时,关闭UITextField中的UIKeyboardTypeNumberPad吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!