【问题标题】:accessibilityPerformEscape does not dismiss UIAlertControllerAccessibilityPerformEscape 不会关闭 UIAlertController
【发布时间】:2016-04-25 05:37:54
【问题描述】:

我正在尝试显示 UIAlertContoller 并在 VoiceOver 用户执行擦洗手势时将其关闭:

override func accessibilityPerformMagicTap() -> Bool {
        showPopup()
        return true
    }

    override func accessibilityPerformEscape() -> Bool {
        print("close")
        return true
    }

    func showPopup(){
        baseAlert = UIAlertController(title: "Popup", message: "Choose an option", preferredStyle: .Alert)
        let firstAction = UIAlertAction(title: "method 1", style: .Default) { (alert: UIAlertAction!) -> Void in
            print("one")
        }

        let secondAction = UIAlertAction(title: "method 2", style: .Default) { (alert: UIAlertAction!) -> Void in
            print("two")
        }

        let thirdAction = UIAlertAction(title: "method 3", style: .Default) { (alert: UIAlertAction!) -> Void in
            print("three")
        }

        let closeAction = UIAlertAction(title: "Close", style: .Destructive) { (alert: UIAlertAction!) -> Void in
            print("close")
            self.accessibilityPerformEscape()
        }

        baseAlert.addAction(firstAction)
        baseAlert.addAction(secondAction)
        baseAlert.addAction(thirdAction)
            baseAlert.addAction(closeAction)

        baseAlert.accessibilityHint = "Pop menu"
        presentViewController(baseAlert, animated: true, completion:
            {
                    self.textField.becomeFirstResponder()
            }
        )


    }

上面的代码显示了UIAlertController,当我执行擦洗手势时,它不会对它做出反应,但是当警报未显示或解除时,转义手势有效。

【问题讨论】:

    标签: swift uiaccessibility


    【解决方案1】:

    您需要在accessibilityPerformEscape() 中添加关闭您的UIAlertController 的代码,返回true 是不够的。

    【讨论】:

      【解决方案2】:

      我认为您的擦洗手势在没有警报视图时有效,因为您在控制器中(导航控制器???)本机考虑了此 VoiceOver 手势。

      但是,您通过覆盖accessibilityPerformEscape 方法为您的警报视图遵循了正确的方法:该问题处理了它的“空”实现,可以通过添加dismiss 订单来根据detailed answer 进行调整。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-05-09
        • 2017-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-16
        • 1970-01-01
        相关资源
        最近更新 更多