Prevent voice transmission (accessibility) from declaring UITableViewCell as selected

When UITableViewCell is selected, the voice on top declares “ selected ”, I do not want the voice to go “selected”. How can I achieve this?

Things I tried without success:

  • AccessibilityHint and accessibilityLabel cell changed
  • Cell selectionStyle = UITableViewCellSelectionStyleNone changed
  • changed cell accessibilityTraits = UIAccessibilityTraitButton

Question:

  • I don’t want the voice to say “selected” when a cell is selected. How can I achieve this?
+7
source share
7 answers

The only work around is to eliminate cell selection

 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath; { return nil; } 

Add Tap gestures to the cell and, when the cell is pressed, do what you want in the cell selection inside the tap gestures.

-2
source

I asked about this as an Apple code level support issue and got the following solution that works great. Use a custom subclass of UITableViewCell, where you override accessibilityTraits, as in the following example:

 class NoTraitCell: UITableViewCell { override var accessibilityTraits: UIAccessibilityTraits { get { return UIAccessibilityTraitNone } set {} } } 
+9
source

You can try unchecking the cell again:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; } 
0
source

You can create your own cell class and override accessibilityTraits as follows:

 - (UIAccessibilityTraits)accessibilityTraits { return UIAccessibilityTraitButton; } 
0
source

If you are not going to use the tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) view selection function tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) do not use tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) . I know I always used this as a didTapOnRowAt method, but it would be better to use willSelectRowAt :

 func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { // code for when a row is tapped return nil } 

return nil means that the cell will not actually be selected.

0
source

What didSelectRow() me was to set the accessibilityLabel cell to " " (the empty line does not work) in didSelectRow() , cause a reboot, and then reset the accessibilityLabel on the next queue.

0
source

You can use the accessibilityElementsHidden property to disable voice access.

If you do not want to hear the presentation in voice mode, set the accessibilityElementsHidden property to true for this particular view ( documentation )

In your case for UITableViewCell you can set it to true in the tableView(_:cellForRowAt:) method tableView(_:cellForRowAt:)

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // write code to create cell .... cell.accessibilityElementsHidden = true return cell } 

Note. You can also set a property in the awakeFromNib() method for a table view cell of a user class.

-1
source

Source: https://habr.com/ru/post/979046/


All Articles