Disable image recognition for UIImageView on iOS 14 with VoiceOver
Asked Answered
P

1

7

I have a UIImageView as the background for a view. User interaction is disabled. isAccessibilityElement is set to NO. This is verified by using debug view hierarchy when the app is running on device.

And yet when I tap on the view that has that as the background is describes all the controls on it and then describes the image using automatic image recognition. Everything I've found online says this is a new iOS 14 feature and that it's great, but says nothing about how I can turn it off.

I even tried setting my own description string to at least try to override the image recognition to no avail. So - IS there a way to turn it off for a specific UIImageView(or even for the app overall) and if so how?

*** update ****

So I've confirmed this is specific to iOS 14. I have the following code in viewDidLoad:

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blueSky.jpg"]];
    imageView.isAccessibilityElement = YES;
    imageView.accessibilityLabel = @"I am not a description";
    CGPoint origin = imageView.frame.origin;
    origin.y = 50;
    origin.x = 50;
    
    CGRect imageFrame = imageView.frame;
    imageFrame.origin = origin;
    imageView.frame = imageFrame;
    self.view.isAccessibilityElement = NO;
    
    [self.view addSubview:imageView];

Where blueSky is, well, an image of blue sky. It's not using the asset catalogue. When I tap on the image with VoiceOver enabled in iOS 13 it reads "I am not a description". When I tap on it on an iOS 14.1 device it reads "I am not a description", then pauses for half a second, says "image", then proceeds to describe it "blue sky, cloudy". It's that last part that I cannot for the life of me figure out how to eliminate!

Pell answered 27/1, 2021 at 15:19 Comment(4)
Where did you find this is a new iOS14 feature, please? 🤔Decennium
It's mentioned in multiple places but here's one example - techcrunch.com/2020/12/03/…Pell
Thanks, I wasn't aware of this new feature... I just knew this one for photos ⟹ a11y-guidelines.orange.com/en/mobile/ios/wwdc/2017/215/…. However, I tried to reproduce your situation and I haven't the description read out when the image view is disabled. Could you output a UI screenshot of your problem in order to reproduce the same one in a blank project, please?Decennium
Oddly enough I can't reproduce it in a blank project either so seems like it's the VERY legacy project I'm working in. I tried to set the accessibilityLabel on the image view to at least override it but it doesn't say the text and instead will say what it thinks is in the image.Pell
P
10

So I found the answer:

imageView.accessibilityTraits = UIAccessibilityTraitNone;

This tells the system to not consider it an image and so it doesn't try to recognize it.

Pell answered 28/1, 2021 at 20:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.