我正在尝试使用openGL视图,特别是来自cocos2d框架的语音。自定义UIView不显示语音上的辅助功能
从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;
现在几个小时的时间我一直在坚持 - 谢谢! –