Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable image recognition for UIImageView on iOS 14 with VoiceOver

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!

like image 921
Ahmad Avatar asked Jan 27 '21 15:01

Ahmad


1 Answers

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.

like image 102
Ahmad Avatar answered Sep 28 '22 04:09

Ahmad