使用 VoiceOver 在 iOS 14 上禁用 UIImageView 的图像识别 [英] Disable image recognition for UIImageView on iOS 14 with VoiceOver

查看:15
本文介绍了使用 VoiceOver 在 iOS 14 上禁用 UIImageView 的图像识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIImageView 作为视图的背景.用户交互被禁用.isAccessibilityElement 设置为 NO.当应用在设备上运行时,这是通过使用调试视图层次结构来验证的.

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.

然而,当我点击作为背景的视图时,它会描述其上的所有控件,然后使用自动图像识别来描述图像.我在网上找到的所有内容都说这是 iOS 14 的一项新功能,它很棒,但没有说明如何关闭它.

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.

我什至尝试将自己的描述字符串设置为至少尝试覆盖图像识别,但无济于事.那么 - 有没有办法为特定的 UIImageView(甚至整个应用程序)关闭它,如果是,如何关闭?

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?

***更新****

所以我已经确认这是特定于 iOS 14 的.我在 viewDidLoad 中有以下代码:

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];

blueSky 是蓝天的图像.它没有使用资产目录.当我在 iOS 13 中启用 VoiceOver 的情况下点击图像时,它会显示我不是描述".当我在 iOS 14.1 设备上点击它时,它会读到我不是描述",然后停顿半秒,说图像",然后继续描述它蓝天,多云".这是我一生都无法弄清楚如何消除的最后一部分!

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!

推荐答案

于是我找到了答案:

imageView.accessibilityTraits = UIAccessibilityTraitNone;

这告诉系统不要将其视为图像,因此不会尝试识别它.

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

这篇关于使用 VoiceOver 在 iOS 14 上禁用 UIImageView 的图像识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆