如何将 UITableVewCell 的可访问性特征设置为仅 'link'?
How can set UITableVewCell's accessibility traits to be 'link' only?
我有一个 UITableViewCell
显示有变色指示器,但打开另一个应用程序而不是推送视图控制器(例如 'Visit our Website',在 Safari 中打开)。我对辅助功能和画外音的有限理解使我相信这应该标记为 'link' 而不是 'button',因为用户将离开该应用程序。为此,我将 accessibilityTraits
设置为 .link
。
但是,一旦我在单元格上设置了披露指示符,该单元格就会显示为“访问我们的网站 - 按钮,link”。
有没有办法保留披露指示符但从单元格中删除 .button
特征?
Is there a way to keep the disclosure indicator but remove the .button trait from a cell?
实现目标的一种方法是创建一个 UITableViewCell
子类,.link
值为 accessibilityTraits
属性 .
class testCell:UITableViewCell {
override var accessibilityTraits: UIAccessibilityTraits {
get { return .link }
set { }
}
}
在您的视图控制器中指示此新单元格类型将仅读出其 link 属性,如下所示:
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> testCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier",
for: indexPath) as! testCell
cell.textLabel?.text = "Visit our Website"
return cell
}
根据这个原理,您可以将 UITableVewCell 的可访问性特征设置为 'link' 仅 。
如果需要,有一个captivating website,其中提供了许多关于特征的信息以及插图和代码片段。
我有一个 UITableViewCell
显示有变色指示器,但打开另一个应用程序而不是推送视图控制器(例如 'Visit our Website',在 Safari 中打开)。我对辅助功能和画外音的有限理解使我相信这应该标记为 'link' 而不是 'button',因为用户将离开该应用程序。为此,我将 accessibilityTraits
设置为 .link
。
但是,一旦我在单元格上设置了披露指示符,该单元格就会显示为“访问我们的网站 - 按钮,link”。
有没有办法保留披露指示符但从单元格中删除 .button
特征?
Is there a way to keep the disclosure indicator but remove the .button trait from a cell?
实现目标的一种方法是创建一个 UITableViewCell
子类,.link
值为 accessibilityTraits
属性 .
class testCell:UITableViewCell {
override var accessibilityTraits: UIAccessibilityTraits {
get { return .link }
set { }
}
}
在您的视图控制器中指示此新单元格类型将仅读出其 link 属性,如下所示:
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> testCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier",
for: indexPath) as! testCell
cell.textLabel?.text = "Visit our Website"
return cell
}
根据这个原理,您可以将 UITableVewCell 的可访问性特征设置为 'link' 仅 。
如果需要,有一个captivating website,其中提供了许多关于特征的信息以及插图和代码片段。