自定义UIView不显示语音上的辅助功能 [英] Custom UIView Not Showing Accessibility on Voice Over
问题描述
我试图使用openGL视图工作,特别是从cocos2d框架。
I'm trying to get voice over working with an openGL view, specifically from the cocos2d framework.
从Apple Accessibility指南,我按照以下部分:使自定义集装箱视图的内容可访问
From the Apple Accessibility guide I followed this section: Make the Contents of Custom Container Views Accessible
我已经将用于实现非正式UIAccessibilityContainer协议的视图(用于cocos2d人的CCGLView)子类化。
I've subclassed the view (CCGLView for cocos2d people), which is a UIView, to implement the informal UIAccessibilityContainer protocol.
UIAccessibilityContainer实现在我的子类UIView中:
-(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数组。但是,当我触摸屏幕时,控制音色不会出现。
This code is getting called and -(NSArray *)acessibilityElements
is returning an array of UIAccessibilityElements. However the voice over controls are not showing up when I touch the screen. Any ideas on what I'm missing or doing wrong?
其他资讯:
我使用故事板并将CCGLView添加到故事板中的UIView。 _director.view是我子类化的CCGLView。
I'm using a storyboard and adding the CCGLView to the UIView in the storyboard. The _director.view is the CCGLView that I subclassed.
// 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以相同的方式,但它也不工作。
For a while I suspected that because I added the subview that this was causing it not to show up, but I also tried subclassing the UIView in the storyboard the same way but it was also not working.
这也是我在数组中创建每个UIAccessibilityElement。 p>
Also this is how I am creating each UIAccessibilityElement in the array.
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;
推荐答案
找到一个解决方案,有这个问题。 - (id)accessibilityElementAtIndex:(NSInteger)index
返回了一个正确的 UIAccessibilityElement
,但看起来它不是由Accessibility API使用它保留。我做了一个强大的NSArray属性来保存UIAccessibilityElements,现在它工作正常。
Found a solution that is working now, in case anyone has this problem. -(id)accessibilityElementAtIndex:(NSInteger)index
was returning a properUIAccessibilityElement
but it looks like it wasn't getting retained by whatever Accessibility API is using it. I made a strong NSArray property to hold the UIAccessibilityElements and now it is working fine.
这篇关于自定义UIView不显示语音上的辅助功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!