I have a UITableViewCell that is displayed with a discolor indicator but opens another application rather than pushing a view controller (for example 'Visit our Website', opening in Safari). My limited understanding of accessibility and voiceover leads me to believe this should be marked as a 'link' rather than a 'button', since the user will be leaving the app. To accomplish this I set the accessibilityTraits to .link.
However, as soon as I set the disclosure indicator on the cell, the cell is read as 'Visit our Website - button, link".
Is there a way to keep the disclosure indicator but remove the .button trait from a cell?
Is there a way to keep the disclosure indicator but remove the .button trait from a cell?
One way to reach your goal is to create a UITableViewCell subclass with the .link value as accessibilityTraits property.👍
class testCell:UITableViewCell {
override var accessibilityTraits: UIAccessibilityTraits {
get { return .link }
set { }
}
}
Indicating this new cell type in your view controller will read out only its link property as follows:🤓
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
}
Following this rationale, you can set UITableVewCell's accessibility traits to be 'link' only.🥳🎊
If need be, there's a captivating website where many informations about the traits are available with illustrations and code snippets.😉
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With