Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImageView not seen by Accessibility Inspector after setting hidden to false when contained in a UITableViewCell

In our application we display a list of items and each item has an image which can either be hidden or displayed.

The issue is that if the image is initially hidden, when we set hidden = false, the image is displayed but the Accessibility Inspector doesn't identify it.

If we call reloadRows then the image is identified by Accessibility Inspector.

However, I want to avoid calling reloadRows when the visibility of the image changes because it adds complexity (weird dependencies).

What I've tried so far is the following:

  • call setNeedsDisplay() on the cell
  • post UIAccessibilityLayoutChangedNotification

Neither work.

Any other ideas of "refreshing / reloading" the cell so the Accessibility Inspector identifies the image?

Please note that I did set an accessibility identifier and isAccessibilityElement is set to true, since after calling reloadRows the image is identified.

Thanks, Cosmin

like image 516
Cosmin Avatar asked Oct 27 '25 01:10

Cosmin


1 Answers

The issue here is due to stack view. If you keep the image view outside the stack view, it should work fine. But since, you are placing it inside the stack view, and by default it's hidden, when the cell loads, accessibility order is determined in such a way that no such element(imageview) exists as it was hidden and stack view shifted other views in image view's place. To make the accessibility inspector read the image view, you need to reload the cell with image view as visible and this time it would work fine.

Alternative to reloading, you can define accessibilityElements for the cell and add image view, if visible, on the basis of isHidden property.

This would make the image view accessibile.

like image 198
imshail31 Avatar answered Oct 28 '25 19:10

imshail31



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!