tmm1
tmm1

Reputation: 2125

Dismiss iOS form sheet modal via outside tap + VoiceOver mode

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?

Upvotes: 3

Views: 3475

Answers (2)

Victor Sanchez
Victor Sanchez

Reputation: 983

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.

Upvotes: 4

tmm1
tmm1

Reputation: 2125

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.

Upvotes: 3

Related Questions