- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的 iOS 应用程序添加辅助功能。我看到一个特定的情况,当我点击具有 isAccessibilityElement = false
的 UIView,并且它的所有祖先 View 也是 isAccessibilityElement = false
时,VoiceOver 会说出来自此 View 的同级 的文本 - 此 View 父级的不同子级。在 Accessibility Inspector 中,当我将鼠标悬停在该 View 上时, sibling 会亮起。
我不明白为什么不在我正在点击的 View 的层次结构中的某些 View 可以用于 VoiceOver 文本。我没有看到任何类似 iOS 11 记录的行为。这怎么会发生?
编辑:我创建了一个带有 UITableView 的简单项目,其中包含 UITableViewCell 对象,每个对象都包含一个 UILabel。点击 UITableViewCell(在 UILabel 之外)将读取其中的 UILabel。我如何禁用该行为,以便仅点击标签本身,而不是点击其包含的 UITableViewCell,将读取标签?
最佳答案
表格 View 单元格 (容器) 及其内容 (子级) 无法一起访问 (解释 here )。
按照以下步骤回答您的编辑提及,以便只点击标签本身,而不是点击其包含的 UITableViewCell
, 会阅读标签。
创建您自己的 UITableViewCell
包含一个标签的类。
class TestTableViewCell: UITableViewCell {
@IBOutlet weak var myLabel: UILabel!
override var accessibilityTraits: UIAccessibilityTraits {
get { return UIAccessibilityTraitNone }
set {}
}
}
将您的标签定义为 UIAccessibilityElement
在要包含在其 accessibilityElements
中的单元实现中数组。
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let zeCell = tableView.dequeueReusableCell(withIdentifier: "myPersoCell",
for: indexPath) as! TestTableViewCell
zeCell.accessibilityElements = nil
var elements = [UIAccessibilityElement]()
let contentA11yElt = UIAccessibilityElement(accessibilityContainer: zeCell)
contentA11yElt.accessibilityTraits = UIAccessibilityTraitStaticText
contentA11yElt.accessibilityFrameInContainerSpace = zeCell.contentLabel.frame //To be adapted
contentA11yElt.accessibilityLabel = "label content"
elements.append(contentA11yElt)
zeCell.accessibilityElements = elements
return zeCell
}
遵循这些代码片段将允许选择位于表格 View 单元格内的标签并根据需要读出其内容。
关于ios - VoiceOver 正在寻找附近的可访问元素来阅读?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50989579/
我的子查询给出了一个错误:Msg 102, Level 15, State 1, Line 17 Incorrect syntax near ')'. SELECT SalesArea, Branch
当我尝试运行此查询时: select branch_no, max (avg_salary) from (select allocatedto, avg (salary) from sta
所以我正在更新 phpmyadmin 中的表。数据在里面,列已成功创建。当我尝试使用下面的代码添加图像时,出现此错误 Unexpected character. (near "\" at positi
我正在尝试在 phpMyAdmin 中执行以下查询,但出现错误。我已经查看过类似的问题,但我仍然无法弄清楚为什么它不起作用。 INSERT INTO discussion_forum (event_t
我正在用 C 构建一个 client-server socket 模拟 我接受来自客户端的 TCP 连接 然后客户端发送消息到我的服务器。我已成功收到消息,然后遍历 structs 的 array 以
我在 AUTOINCREMENT 附近遇到语法错误。这个错误的原因是什么? CREATE TABLE person ( id INTEGER NOT NULL AUTOINCREMENT,
当我尝试使用 java 在 SQLite 中以编程方式创建数据库时,它会在控制台中生成以下错误。 java.sql.SQLException: near "DATABASE": syntax erro
我似乎无法弄清楚出了什么问题。我尝试查询的子部分,但仍然无法解决问题。 表格格式: poi(id int, minX float, minY float, maxX float, maxY float
我在VHDL中编写了以下代码: library IEEE ; use IEEE.STD_LOGIC_1164.all ; entity encoder is port( x : in std_
我在我的游戏服务器中使用这些文件,每次我添加一个新的玩家模型时,我都会得到 [ERROR] lua/autorun/server/fastdlskins.lua:938: '' expected ne
我正在尝试更新我的 sqlite3 数据库,但出现此错误。我能够成功地将数据插入同一数据库,但无法更新它。请帮忙。 [SQLITE_ERROR] SQL error or missing databa
我想在通知区域旁边显示一个小弹出窗口。它类似于 Outlook/Skype/Live! Messenger/etc 在显示有关新消息的通知时会执行此操作。在我的例子中,它将有一些输入控件(文本框、日期
我正在尝试编写简单的程序以使用 gorp 将行插入表中,但在创建表时出现错误。 代码如下: package main import _ "github.com/mattn/go-sqlite3" im
我正在尝试运行工作目录中的 Octave 文件,但出现错误。 Octave 似乎没有认识到它应该运行该文件。 unknown@unknown> dir .
我正在尝试编写一些代码来模拟具有两个三态缓冲器和VHDL中的上拉电阻的电路。下面是我的代码: library ieee; use ieee.std_logic_1164.all; entity Pul
你能好心告诉我这里出了什么问题吗? conn 是 DriverManager.getConnection(DB_URL) try { PreparedState
我想在go中创建一个事务,同时这样做会出现错误:near "SET": syntax error。代码: db.Exec("SET TRANSACTION ISOLATION LEVEL REPEAT
所以我想用这样的颜色可视化一个矩阵 library(RColorBrewer) vec = rbinom(10000,1,0.1) n = sum(vec) vec = ifelse(vec == 1
private static final String QUERY = "SELECT * FROM " + TABLE_SONG_DETAILS + " WHERE " + TABLE_SONG_D
希望大家一切都好。 我正在尝试创建一个 mysql 触发器,但是我不断收到以下错误: [Err] 1064 - You have an error in your SQL syntax; check
我是一名优秀的程序员,十分优秀!