在UITableView标头中包含的UIImageView上设置accessibilityLabel [英] setting an accessibilityLabel on a UIImageView contained in UITableView header

查看:1155
本文介绍了在UITableView标头中包含的UIImageView上设置accessibilityLabel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 loadView 中构建了 UITableView 。我在 loadView 中做的一件事是创建一个 UIView 作为表头并填充 UIImageView 进入它。图像视图包含一个风格化标题的图像,因此我想为VoiceOver用户添加一个辅助功能标签。但是,我无法让VoiceOver聚焦在图像上以便读取标签,并且Accessibility Inspector不会响应在模拟器中单击图像。我的(缩写)代码如下:

I have a UITableView that I build in loadView. One of the things I do in loadView is create a UIView to act as the table header and stuff a UIImageView into it. The image view contains an image that is a stylized title, so I want to add an accessibility label for VoiceOver users. However, I can't get VoiceOver to "focus" on the image in order to read the label, and the Accessibility Inspector doesn't respond to clicking on the image in the simulator. My (abbreviated) code follows:

... in -loadView ...
// Make header view
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(...)];
UIImageView *titleImageView = [[UIImageView alloc] initWithImage:[self titleImage]];
titleImageView.accessibilityLabel = [self accessibilityLabelForTitleImage];
[headerView addSubview:titleImageView];

// Make table view
self.tableView = [[UITableView alloc] initWithFrame:CGRect(...) style:UITableViewStylePlain];
self.tableView.tableHeaderView = headerView;
... code continues ...

我已经介入了gdb和 accessibilityLabelForTitleImage 返回一个字符串。 po [titleImageView accessibilityLabel] 打印出正确的字符串,但我仍然无法专注于图像视图。请注意,视图本身会显示并作出适当的响应。

I've stepped through in gdb and accessibilityLabelForTitleImage returns a string. po [titleImageView accessibilityLabel] prints out the correct string, but I'm still unable to focus on the image view. Note that the views themselves appear and respond as appropriate.

我错过了什么吗?有没有办法强制VoiceOver确认图像视图?

Am I missing something? Is there a way to force VoiceOver to acknowledge an image view?

推荐答案

在画外音中,为了使元素可访问: -

In Voice-Over , in order to make an element accessible :-


  1. 你必须将setIsAccessibilityElement属性设置为true,我在你的代码中找不到。

  1. you have to set setIsAccessibilityElement property as true which i don't find in your code.

另一个重要的一点是,要使子元素(子视图)可访问,您必须单独使它们可访问,而父元素不可访问(您必须指定此另外)。

The other important point is that to make child elements (subviews) to be accessible , you have to seperately make them accessible while the parent should not be accessible(you have to specify this also).

在自定义单元格中实现UIAccessibilityContainer协议。

Implement the UIAccessibilityContainer Protocol in your custom - cell.

如果我继续这将是一个大故事。请参考这个苹果可访问语音

It will be a big story if i go on .Please refer this Accessibility voice over by apple.

希望这有帮助。

这篇关于在UITableView标头中包含的UIImageView上设置accessibilityLabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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