Disable image recognition for UIImageView on iOS 14 with VoiceOver

我与影子孤独终老i 提交于 2021-02-10 06:47:26

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/65922080/disable-image-recognition-for-uiimageview-on-ios-14-with-voiceover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!