UIAlertController处于活动状态时,不会触发VoiceOver Z手势

编程入门 行业动态 更新时间:2024-10-11 03:15:47
本文介绍了UIAlertController处于活动状态时,不会触发VoiceOver Z手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Z手势关闭UIAlertController.我有一个非常简单的应用程序.它具有1个按钮的单个视图.轻击按钮会发出警报.我已经实现了

I'm trying to use the Z gesture to dismiss a UIAlertController. I have a very simple app. It has a single view with 1 button. Tapping the button presents an alert. I have implemented

- (BOOL)accessibilityPerformEscape { NSLog(@"Z gesture"); return YES; }

在启用VoiceOver的情况下,擦洗屏幕会打印出"Z手势",但是当我按下按钮并且看到警报时,擦洗屏幕不会执行任何操作,不会调用该方法,也不会打印任何内容.我该怎么办才能使警报在屏幕上显示出来?

With VoiceOver on, scrubbing the screen prints out "Z gesture," but when I press the button and the alert is visible, scrubbing the screen does nothing, the method is not called and nothing is printed. What do I have to do to get this to function while the alert is on screen?

谢谢...

推荐答案

由于要进行擦洗手势,因此要在警报视图中获得所需的结果,请在警报视图本身中覆盖accessibilityPerformEscape().

To get the desired result on your alert view thanks to the scrub gesture, override accessibilityPerformEscape() in the alert view itself.

解决方案可能是在UIView扩展中实现此替代,如下所示:

A solution could be to implement this override in an UIView extension as follows :

extension UIView { override open func accessibilityPerformEscape() -> Bool { if let myViewController = self.findMyViewController() as? UIAlertController { myViewController.dismiss(animated: true, completion: nil) } return true } private func findMyViewController() -> UIViewController? { if let nextResponder = self.next as? UIViewController { return nextResponder } else if let nextResponder = self.next as? UIView { return nextResponder.findMyViewController() } else { return nil } } }

该代码足够简短,无需进一步说明即可理解.如果不清楚,请不要犹豫.

The code is short enough to be understood without further explanation. If it's not clear, don't hesitate to ask.

已找到功能findMyViewController 此处.

更多推荐

UIAlertController处于活动状态时,不会触发VoiceOver Z手势

本文发布于:2023-11-27 15:35:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638587.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:手势   状态   UIAlertController   VoiceOver

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!