【问题标题】:Custom UIView Not Showing Accessibility on Voice Over自定义 UIView 不显示旁白的可访问性
【发布时间】:2012-11-19 20:54:09
【问题描述】:

我正在尝试通过使用 openGL 视图(特别是来自 cocos2d 框架)进行配音。

从 Apple 辅助功能指南中,我遵循了以下部分:Make the Contents of Custom Container Views Accessible

我将视图(cocos2d 的 CCGLView)子类化了,它是一个 UIView,用于实现非正式的 UIAccessibilityContainer 协议。

我的子类 UIView 中的 UIAccessibilityContainer 实现:

-(NSArray *)accessibilityElements{
return [self.delegate accessibleElements];
}

-(BOOL)isAccessibilityElement{
return NO;
}
-(NSInteger)accessibilityElementCount{
return [self accessibilityElements].count;
}
-(NSInteger)indexOfAccessibilityElement:(id)element{
return [[self accessibilityElements] indexOfObject:element];
}
-(id)accessibilityElementAtIndex:(NSInteger)index{
return [[self accessibilityElements] objectAtIndex:index];
}

此代码被调用,-(NSArray *)acessibilityElements 返回一个 UIAccessibilityElements 数组。但是,当我触摸屏幕时,没有显示语音控制。关于我遗漏或做错了什么的任何想法?

其他信息:

我正在使用情节提要并将 CCGLView 添加到情节提要中的 UIView。 _director.view 是我子类化的 CCGLView。

 // Add the director as a child view controller.
[self addChildViewController:_director];

// Add the director's OpenGL view, and send it to the back of the view hierarchy so we can place UIKit elements on top of it.
[self.view addSubview:_director.view];
[self.view sendSubviewToBack:_director.view];

有一段时间我怀疑是因为我添加了导致它不显示的子视图,但我也尝试以相同的方式在情节提要中对 UIView 进行子类化,但它也不起作用。

这也是我在数组中创建每个 UIAccessibilityElement 的方式。

UIAccessibilityElement *elm = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:view];
    elm.accessibilityFrame = f;
    elm.accessibilityLabel = t.letter;
    elm.isAccessibilityElement = YES;
    elm.accessibilityHint = @"Button";
    elm.accessibilityValue = t.letter;
    elm.accessibilityTraits = UIAccessibilityTraitButton;

【问题讨论】:

    标签: objective-c ios cocos2d-iphone accessibility uiaccessibility


    【解决方案1】:

    找到了一个现在有效的解决方案,以防万一有人遇到这个问题。 -(id)accessibilityElementAtIndex:(NSInteger)index 正在返回一个正确的UIAccessibilityElement 但看起来它没有被任何使用它的辅助功能 API 保留。我创建了一个强大的 NSArray 属性来保存 UIAccessibilityElements,现在它工作正常。

    【讨论】:

      猜你喜欢
      • 2014-06-22
      • 2012-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多