![](/img/trans.png)
[英]iOS accessibility - How do you set the accessibility label for the title of a UINavigationBar?
[英]How do you set the accessibility label on an image that is drawn with Core Graphics?
我试图围绕一些核心图形逻辑编写UIAutomation测试。 目前我们正在使用核心图形来绘制图像。 我正在尝试在图像上设置辅助功能标签/标识符/值,以便我可以通过UIAutomation测试验证其存在,但无论我做什么,我都没有获得DOM上的辅助功能标签/标识符/值我的考试。 以下是我尝试过的事情:
直接在图像上设置。
UIImage *uiImage = [UIImage imageWithData:bfCaseStudy.image];
uiImage.isAccessibilityElement = YES;
uiImage.accessibilityLabel = bfCaseStudy.name;
uiImage.accessibilityValue = bfCaseStudy.name;
uiImage.accessibilityIdentifier = bfCaseStudy.name;
CGContextDrawImage(context, [self rectForAttr:bfCaseStudy], uiImage.CGImage);
在核心图像上设置
UIImage *uiImage = [UIImage imageWithData:bfCaseStudy.image];
uiImage.CIImage.isAccessibilityElement = YES;
uiImage.CIImage.accessibilityLabel = bfCaseStudy.name;
uiImage.CIImage.accessibilityValue = bfCaseStudy.name;
CGContextDrawImage(context, [self rectForAttr:bfCaseStudy], uiImage.CGImage);
无论哪种方式都会产生相同的结果。 这是试图访问信息的UIAutomation代码。
UIALogger.logDebug(bookTwoHelper.mainWindow.images()[5].label());
UIALogger.logDebug(bookTwoHelper.mainWindow.images()[5].name());
UIALogger.logDebug(bookTwoHelper.mainWindow.images()[5].value());
Debug: (2013-02-25 16:06:33 +0000) - (null)
Debug: (2013-02-25 16:06:33 +0000) - (null)
Debug: (2013-02-25 16:06:33 +0000) - (null)
这是DOM的相关部分
UIAImage "(null)" {{0, 149}, {316, 55}}
有没有办法在使用核心图形绘制的图像上设置辅助功能标签/标识符/值?
像accessibilityLabel
这样的属性仅在与UIVit控件(如UIView
, UIImageView
等)一起使用时才有效。因为你的图像不是真正的UIView
,你需要通过使容器视图或视图控制器实现UIAccessibilityContainer
协议来为UIKit提供额外的信息。
有关详细信息, 请参阅“适用于iOS的辅助功能编程指南” ,尤其是使自定义容器视图的内容可访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.