如何禁用自定义静态UITableViewCell的可访问性 [英] How to disable accessibility for custom static UITableViewCell

查看:74
本文介绍了如何禁用自定义静态UITableViewCell的可访问性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个故事板,其中包含带有静态内容的 UITableViewController .这些单元非常简单,仅包含一个 UILabel .如果现在我想禁用其中一个单元的可访问性,则只需取消选中标签上的标记.这样可以正常工作.

I have a storyboard containing a UITableViewController with static content. The cells are very simple, containing just a single UILabel. If I now want to disable accessibility on one of the cells, I simply uncheck the mark on the label. This works as expected.

但是,如果现在我创建一个 UITableViewCell 的空子类并将其用作我的静态单元格的单元格类,则会启用可访问性,而忽略所有设置.

However if I now create an empty subclass of UITableViewCell and use this as the cell class for my static cell, accessibility will be enabled, ignoring all settings.

我尝试覆盖 -isAccessibilityElement 以返回 NO ,以编程方式将所有子视图的 accessibilityElement 属性设置为 NO ,但在使用VoiceOver时仍然可以选择.VoiceOver不会读取内容,似乎只有一个"(向上/向下滑动此元素时可以听到).

I tried overriding -isAccessibilityElement to return NO, programmatically setting all child views accessibilityElement property to NO, but it still will be selectable when using VoiceOver. The content won't be read by VoiceOver, only a single " " seems to be there (can be heard when swiping up/down on this element).

我该怎么做才能禁用自定义单元的可访问性?

What do I need to do to disable accessibility for my custom cell?

推荐答案

也许,这种方法更容易.

Maybe, this way is easier.

cell.textLabel.accessibilityElementsHidden = YES;

查看此帖子

;)

这篇关于如何禁用自定义静态UITableViewCell的可访问性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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