UIAccessibilityFocus协议无法正常工作 [英] UIAccessibilityFocus protocol not working

查看:220
本文介绍了UIAccessibilityFocus协议无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道用户何时将焦点从辅助功能元素移开。我试过覆盖 accessibilityElementDidLoseFocus() accessibilityElementDidBecomeFocused()方法,但似乎没有调用这些方法当我导航到VoiceOver辅助功能模式中的其他元素时。我不知道出了什么问题。我还有什么办法可以激活这些方法吗?

I want to know when a user shifts the focus away from an accessibility element. I have tried overriding the accessibilityElementDidLoseFocus() and accessibilityElementDidBecomeFocused() methods but the methods doesn't seem to be called upon when I navigate to other elements in VoiceOver accessibility mode. I have no idea what is wrong. Is there anything else that I should do to activate these methods?

override func accessibilityElementDidBecomeFocused() {
    println("become focused")
}

override func accessibilityElementDidLoseFocus() {
    println("lose focus")
}

目前的开发是在iOS 8.1上,使用Swift。

The current development is on iOS 8.1, using Swift.

推荐答案

在最初的问题之后超过2年,但我希望这无论如何都会有所帮助。

More than 2 years after the initial question but I hope this will help anyway.

出现问题是因为您可能在视图控制器中覆盖了这些方法,你应该直接在你的辅助功能元素中实现你的代码。

The problem occurs because you may have overriden these methods in your view controller, you should implement your code in your accessibility element directly.

你可以创建一个类来定义accessibility元素,或者只是在你放置<$的地方扩展它的超类c $ c> UIAccessibilityFocus 覆盖函数。

You could create a class to define the accessibility element or just make an extension of its superclass where you put the UIAccessibilityFocus overriden functions.

这篇关于UIAccessibilityFocus协议无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆