Dismiss a UIKeyboardTypeNumberPad in a UITextField when VoiceOver is active?

850 views Asked by At

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

There are 1 answers

1
MobA11y On BEST ANSWER

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.