【发布时间】: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