3

On an iPad, you can use controller.modalPresentationStyle = UIModalPresentationFormSheet to show a centered modal on the screen. A common technique is to allow the user to dismiss the modal by clicking "outside" or "behind" it. This is covered in numerous other answers (Iphone SDK dismissing Modal ViewControllers on ipad by clicking outside of it, Dismiss modal view form sheet controller on outside tap), usually by adding a tap gesture to the view's UIWindow.

My question is, how do I make this accessible to users in VoiceOver mode? The native action sheets allow clicks outside the sheet to dismiss, and even prompt the user, saying "double tap to dismiss popup window". How can I expose the UIWindow tap gesture in the same way?

tmm1
  • 2,025
  • 1
  • 20
  • 35
  • One option is to implement the "global escape gesture" (as described in http://ronnqvi.st/adding-accessible-behavior) via `accessibilityPerformEscape`. However this is not very discoverable if the user doesn't know about the gesture already. – tmm1 Jun 20 '18 at 02:28
  • FYI - the default ability to dismiss an action sheet or other popovers by tapping outside of them is built into controllers presented with the modal presentation style of "popover". – rmaddy Jun 20 '18 at 02:48
  • @rmaddy is correct - the system provides that ability automatically, and the form sheet style does not support tap outside to dismiss (not for VO users or for non-VO users) – Jordan H Jun 25 '18 at 01:29

2 Answers2

4

From Apple:

https://support.apple.com/guide/iphone/learn-voiceover-gestures-iph3e2e2281/ios

Dismiss an alert or return to the previous screen: Two-finger scrub (move two fingers back and forth three times quickly, making a “z”).

If the modal sheet is opened, we can prompt the user to "make a z gesture" to go back.

Victor Sanchez
  • 960
  • 2
  • 12
  • 26
  • That's THE solution in my view but it can't be explained to your app VoiceOver users who don't know it and then can't figure out how to leave this kind of modal view unfortunately: many of them aren't aware of this specific gesture. – XLE_22 Dec 06 '19 at 07:41
  • Is it safe to assume that the user is used to do a gesture to read all items on screen? "Swipe up with two fingers to read everything onscreen."? If the user is used to doing this, one option could be to use something like hints. For example set a hint on the first element of screen "To go back, perform a Z gesture with your two fingers". Something like that message. https://developer.apple.com/documentation/uikit/uiaccessibilityelement/1619585-accessibilityhint – Victor Sanchez Dec 06 '19 at 08:37
  • I'm not sure they all know the 2-fingers gesture neither but it's not blocking: you can iterate items by another way but that's not the case for leaving a modal view with the Z gesture. Moreover, take care with hints that can be ignored thanks to the device settings: I suggest to not count on hints to provide important info. – XLE_22 Dec 06 '19 at 08:42
3

There is basically no way to do this with the FormSheet presentation. You can use the Popover presentation, but it behaves differently in some cases.

My solution was to check UIAccessibilityIsVoiceOverRunning() and add an extra close button element to the top of FormSheet that can be clicked via voiceover. I also implemented accessibilityPerformEscape for the global escape gesture.

tmm1
  • 2,025
  • 1
  • 20
  • 35
  • You can also simply add a tap gesture to your popover only when in voiceover and use that to dismiss, instead of adding another button. Your solution led me to this fwiw :) – BHendricks Apr 18 '19 at 17:38