简体   繁体   English

通过外部点击 + VoiceOver 模式关闭 iOS 表单模式

[英]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.在 iPad 上,您可以使用controller.modalPresentationStyle = UIModalPresentationFormSheet在屏幕上显示居中的模态。 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.这在许多其他答案中都有介绍( Iphone SDK 通过在 ipad 外部点击它来关闭Modal ViewControllers, 在外部点击关闭模态视图表单控制器),通常是通过向视图的 UIWindow 添加点击手势。

My question is, how do I make this accessible to users in VoiceOver mode?我的问题是,如何在 VoiceOver 模式下让用户可以访问它? 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?如何以相同的方式公开 UIWindow 点击手势?

There is basically no way to do this with the FormSheet presentation.对于 FormSheet 演示文稿,基本上没有办法做到这一点。 You can use the Popover presentation, but it behaves differently in some cases.您可以使用 Popover 演示文稿,但在某些情况下它的行为会有所不同。

My solution was to check UIAccessibilityIsVoiceOverRunning() and add an extra close button element to the top of FormSheet that can be clicked via voiceover.我的解决方案是检查UIAccessibilityIsVoiceOverRunning()并在 FormSheet 的顶部添加一个额外的关闭按钮元素,可以通过画外音单击。 I also implemented accessibilityPerformEscape for the global escape gesture .我还为全局转义手势实现了accessibilityPerformEscape

From Apple:来自苹果:

https://support.apple.com/guide/iphone/learn-voiceover-gestures-iph3e2e2281/ios 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”).解除警报或返回上一屏幕:两指擦洗(快速来回移动两根手指 3 次,形成“z”)。

If the modal sheet is opened, we can prompt the user to "make az gesture" to go back.如果模态表打开,我们可以提示用户“做az手势”返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM